Email not working for office365 email

I am sending email from my gmail account from last few months but not i want to use Office365 account to send emails.
i am using following code of curl MBS, but it returning error code 37 (error:1408F10B:SSL routines:ssl3_get_record:wrong version number)

Here is my code-

dim e as new CURLEmailMBS

e.SetFrom txtSenderEmailID.Text, "Test "
e.Subject ="Daily Sales Journal For "
e.SMTPPassword =txtPassword.Text
e.SMTPUsername = txtSenderEmailID.Text
e.SMTPServer= “smtp.office365.com
e.SetServer “smtp.office365.com”, true
e.UseSSL =True
e.AddTo txtReceiverEmailID.Text, “”
e.PlainText = “Hello Test”

dim c as new CURLSMBS
c.OptionPort= 587
c.OptionUseSSL= 3
c.OptionSSLVerifyHost= 2
c.OptionSSLVerifyPeer= 1
c.OptionSSLVersion= 6

if c.SetupEmail(e) then
dim er as Integer = c.Perform
if er = 0 then
app.prowritelog( “Email sent” , “SendEmail”)
else
app.prowritelog( “Email sending Failed” , “SendEmail”)
end if
end if

Christian can probably help you on this one.

I’m using his excellent plugins heavily, but as a general rule, I’m only using plugins when I can’t solve an issue with Xojo “out-of-the-box”. For Office365, a SMTPSecureSocket works well enough for me. I’m posting my code excerpt if you want to move on until you have an answer for the CURL plugin.

theMailServer.SSLEnabled = True
theMailServer.Address = "smtp.office365.com" 
theMailServer.SSLConnectionType = SSLSocket.SSLConnectionTypes.TLSv12 
theMailServer.SMTPConnectionMode = SMTPSecureSocket.ModeSTARTTLS
theMailServer.Username = "YOUROFFICE365EMAILACCOUNT"
theMailServer.Password = "YOUROFFICE365PASSWORD"
theMailServer.Port = 587 

// Create the actual email message
Var mail As New EmailMessage
mail.FromAddress = "YOUROFFICE365EMAILACCOUNT"
mail.AddRecipient(mailto)
mail.Subject = mailSubject
mail.Headers.AddHeader("Content-type", "text/html; charset=utf-8;")
mail.BodyHTML = mailMessage

// Add the message to the SMTPSocket and send it
theMailServer.Messages.Add(mail)

// Send the E-Mail
theMailServer.SendMail

It looks like something is wrong with the SSL type you selected…

e.SetServer “smtp.office365.com”, true

don’t pass true there.
SSL directly doesn’t work. You have to connect in plain text and then use TLS upgrade.

1 Like