Question

Is there some trick to making VBScript CDO work with Amazon SES SMTP? I dont get any errors, but it doesn't send me my test e-mail either. Changing SSL to False does give me a 530 error, so I know I am at least reaching the server. What am I doing wrong?

EmailSubject = "Sending Email by CDO"
EmailBody = "This is the body of a message sent via" & vbCRLF & _
        "a CDO.Message object using SMTP authentication."

Const EmailFrom = "yyy@xxx.com"
Const EmailFromName = "Me Test"
Const EmailTo = "eee@aaa.com"
Const SMTPServer = "email-smtp.us-east-1.amazonaws.com"
Const SMTPLogon = "xxxxxx"
Const SMTPPassword = "xxxxxxx"
Const SMTPSSL = True
Const SMTPPort = 25

Const cdoSendUsingPickup = 1    'Send message using local SMTP service pickup directory.
Const cdoSendUsingPort = 2  'Send the message using SMTP over TCP/IP networking.

Const cdoAnonymous = 0  ' No authentication
Const cdoBasic = 1  ' BASIC clear text authentication
Const cdoNTLM = 2   ' NTLM, Microsoft proprietary authentication

' First, create the message

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = EmailSubject
objMessage.From = """" & EmailFromName & """ <" & EmailFrom & ">"
objMessage.To = EmailTo
objMessage.TextBody = EmailBody

' Second, configure the server

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPLogon

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = SMTPSSL

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

' Now send the message!

objMessage.Send
Was it helpful?

Solution

CDO does not support TLS, but only SSL. AWS SES will let you use SSL over TCP port 465. Trying to use SSL over port 25 like you have in the script you posted should return the following error message:

CDO.Message.1: The transport lost its connection to the server.

I don't know why you don't get that error with this script. I do. Try changing the port to 465. When I change the port to 465, it works.

OTHER TIPS

This is a great routine. You need to declare objMessage as an object:

Dim objMessage as Object

Also, since he is using Const, if you want to change any of these items, you will need to declare them as strings and remove the Const from those lines. I had to substitute 465 for the SMTPPort, use my SES id/pw, and it works perfect!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top