I had a very similar function working a couple years ago but now I can’t send an email using the gmail SMTP server.
I DO have the ‘use less secure apps’ switch turned on.
I execute the following code, the LastErrorCode is 0 but the email is never delivered to the recipient’s inbox. It just disappears.
Has gmail changed some of the required settings or what else could be wrong?
[code]Dim oMail As EmailMessage
Dim i As Integer
Dim s As String
dim sMessage1 As String
dim sMessage2 As String
dim sMessage3 As String
dim sMessageFull As String
sMessage1 = "Greetings Brother " + oMember.sFirstName + Chr(10) + Chr(10)
sMessage2 = taMessage.Text + Chr(10) + Chr(10)
sMessage3 = taSignature.Text
sMessageFull = sMessage1 + sMessage2 + sMessage3
MailSocket.Address = “smtp.gmail.com”
MailSocket.Port = 465
MailSocket.ConnectionType = SMTPSecureSocket.TLSv1
MailSocket.SMTPConnectionType = SMTPSecureSocket.SMTPConnectionTypes.SSLTLS
MailSocket.Secure = True
MailSocket.Username = sSMTPAccount
MailSocket.Password = sSMTPPassword
oMail = New EmailMessage
oMail.FromAddress = “@gmail.com"
oMail.AddRecipient("*@gmail.com”)
oMail.Subject = tfSubject.Text
oMail.BodyPlainText = sMessageFull
oMail.Headers.AppendHeader(“X-Mailer”,“SMTP Test”)
MailSocket.Messages.Append(oMail)
MailSocket.SendMail
i = MailSocket.LastErrorCode
s = "Message Result = " + Str(i)
MsgBox(s)
if i = 0 then
lblResult.Visible = True
lblResult.Text = “Successful”
lblResult.TextColor = Color.Blue
else
lblResult.Visible = True
lblResult.Text = “Failed”
lblResult.TextColor = Color.Red
end if
[/code]