Using CDO/SMTP/TLS in VB6 to send email mail server

vbscript send email using office 365
office 365 smtp without tls
office 365 smtp settings
cdo.message vba
the transport failed to connect to the server vba
vba smtp email
vbscript send email starttls
office 365 starttls

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

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


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 = ""
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("") = 2
Configuration.Fields.Item("") = ""
Configuration.Fields.Item("") = 25
Configuration.Fields.Item("") = 1
Configuration.Fields.Item("") = ""
Configuration.Fields.Item("") = "YourPass"
Configuration.Fields.Item("") = True


Set Message.Configuration = Configuration

End Sub

Use CDO to send email from VBScript or VBA through Office 365, The server response was: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM. So clearly The trick is not to use TLS at all​, but to use SSL instead on port 25 instead, which seems to work fine: VBScript to Send Email via Office 365 ( This is just  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 . Is there any way I could have TLS via 587 in VB6? Thanks

This code worked for me until a few days ago when we switched ISP's (or maybe something changed coincidentally on the server side). If I specify port 587, I get a transport error and have not found the solution for that with VBA. Please let me know if this works for you and if you find a way to use 587. (Port 25 doesn't work for me either, same error.)

Public Function SMTPSend(vSendTo, vsubject As Variant, vmessage As Variant)
'This works
Set emailObj = CreateObject("CDO.Message")

emailObj.From = ""
emailObj.To = vSendTo
emailObj.Subject = vsubject
emailObj.TextBody = vmessage
'emailObj.AddAttachment "c:\windows\win.ini"

Set emailConfig = emailObj.configuration

emailConfig.Fields("") = 2
emailConfig.Fields("") = 1
emailConfig.Fields("") = ""
'Must exclude port if specifying SSL
'emailConfig.Fields("") = 587
emailConfig.Fields("") = True
emailConfig.Fields("") = ""
emailConfig.Fields("") = "mypassword"


If Err.Number = 0 Then SMTPSend = True Else SMTPSend = False

End Function

Send Email using Hotmail/Live/Outlook/Office 365 in VB 6.0, Hotmail/Live/ SMTP server address is . Mail oSmtp. demonstrate how to send email using Office 365 in VB6 over TLS 587 port. As I mentioned earlier, it is still possible to send email via CDO and use an external SMTP server by using the "Smart Host" setting at the local SMTP server level. This does mean the local SMTP service will need to be running, but it does allow you to set SMTP permissions and settings in one place.

I don't know if you could fix it, but I got it with this:

Private Sub Command1_Click()

Dim oSmtp As New EASendMailObjLib.Mail
oSmtp.LicenseCode = "TryIt"

' Set your Hotmail email address
oSmtp.FromAddr = ""

' Add recipient email address
oSmtp.AddRecipientEx "", 0

' Set email subject
oSmtp.Subject = "test email from hotmail account"

' Set email body
oSmtp.BodyText = "this is a test email sent from VB 6.0 project with hotmail"

' Hotmail SMTP server address
oSmtp.ServerAddr = ""

' Hotmail user authentication should use your 
' Hotmail email address as the user name. 
oSmtp.UserName = ""
oSmtp.Password = "yourpassword"

' Set port to 25, if you want to use 587 port, please change 25 to 587
oSmtp.ServerPort = 25

' detect SSL/TLS connection automatically

MsgBox "start to send email ..."

If oSmtp.SendMail() = 0 Then
    MsgBox "email was sent successfully!"
    MsgBox "failed to send email with the following error:" & oSmtp.GetLastErrDescription()
End If

End Sub


Remember download the library:

Just Replace Parameters!

VB6, we're migrating to and I'm not longer able to use mails. server port 25 or 587 (which are open both)​/07/13/sending-smtp-mail-via-office-365-exchange-using-cdo-m  objMessage.Send %> If you run into problems when using this code, please post in the DiscountASP.NET or Everleap community forum. Technical support is unable to assist with specific coding issues.

Solved: sending mail via CDO and, We love Office 365, specifically the Exchange/Outlook email features such as Sending SMTP mail via Office 365 exchange using CDO. Encryption method: TLS I use VB Script from a Windows 2008 server as follows:  Hi, we're migrating to and I'm not longer able to use mails. basicaly, my parameters are : - sendusing 2 - smtpserver - server port 25 or 587 (which are open both) - smtpauthenticate 1 with or without sptmusessl any help would be greatly appreciated thanks

Sending SMTP mail via Office 365 exchange using CDO.Message , By default, Office 365 SMTP server uses 587 port and explicit SSL (TLS) connection. [VB 6.0 - Send email using Office 365 over explicit SSL  I'm not familar with the INDY SMTP component. I want to send a mail with INDY and Office 365. Here is a nice topic which helped me a lot: What do the SMTP Indy component security and authentication properties do? But I did not figured out how to use SASL. Office365 adress is with port 587 and TLS.

VB6 Send Mail Office 365, Configure the SMTP Server on your Exchange Server to send emails with With Office 365, Microsoft hosts Outlook and your emails in the cloud Once configured, you can send emails on behalf of all the email addresses in your Connection Type: TLS; Server Name:; Port: 587 or 25  Installation¶. EASendMail is a SMTP component which supports all operations of SMTP/ESMTP protocols (RFC 821, RFC 822, RFC 2554). Before you can use the following example codes, you should download the EASendMail Installer and install it on your machine at first.

  • If anyone found this page wondering how to send an email from Excel using CDO, I threw together a Google Doc How to Send Email from Excel using Gmail with code on GitHub gist
  • When I set the port it doesn't work. When I leave the smtpserverport field off, I assume it defaults to port 25. I found our new ISP blocks 25. Looking around, it appears CDO or VBA doesn't correctly pass the smtpserverport. If anyone knows the secret, there are many posts like this one that can use the help.
  • A .NET library does not help with VB6 or Classic ASP code.
  • You posted this as an answer. This is not an answer, it's another question.
  • With CDO not works to me, for that reason I use this library "easendmail". Download: