Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using CDO/SMTP/TLS in VB6 to send email smtp.office365.com mail server

I am searching for days to find out how can I set Office365 SMTP server in my VB6 application. My code is working properly with port 465 and other mail servers. BUT it is not working with port 587 and smtp.office365.com

Is there any way I could have TLS via 587 in VB6?

Thanks

like image 701
Al007 Avatar asked Jan 06 '23 23:01

Al007


1 Answers

With this code, I get to send mail using CDO to Office365.

    Private Message As CDO.Message
Private Attachment, Expression, Matches, FilenameMatch, i

Sub enviar_mail()

Set Message = New CDO.Message
Message.Subject = "Test Mail"
Message.From = "[email protected]"
Message.To = ""
Message.CC = ""
Message.TextBody = "my text body here"

Dim Configuration
Set Configuration = CreateObject("CDO.Configuration")
Configuration.Load -1 ' CDO Source Defaults
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPass"
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

Configuration.Fields.Update

Set Message.Configuration = Configuration
Message.Send

End Sub

like image 161
Jhony Donosso Gutierrez Avatar answered Feb 08 '23 15:02

Jhony Donosso Gutierrez