是否有一些技巧使VBScript CDO与Amazon SES SMTP协同工作?

时间:2012-10-10 05:18:49

标签: vb.net vbscript smtp amazon-ses cdo.message

是否有一些技巧可以使VBScript CDO与Amazon SES SMTP协同工作?我没有收到任何错误,但它也没有发送给我我的测试电子邮件。将SSL更改为False确实给我530错误,所以我知道我至少到达了服务器。我做错了什么?

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

2 个答案:

答案 0 :(得分:7)

CDO不支持TLS,但只支持SSL。 AWS SES将允许您通过TCP端口465使用SSL。尝试在端口25上使用SSL,就像您在发布的脚本中一样,应该返回以下错误消息:

CDO.Message.1:传输失去了与服务器的连接。

我不知道你为什么不用这个脚本得到那个错误。我做。尝试将端口更改为465.当我将端口更改为465时,它可以正常工作。

答案 1 :(得分:0)

这是一个很好的例程。您需要将objMessage声明为对象:

将objMessage变暗为对象

此外,由于他正在使用Const,如果要更改任何这些项,则需要将它们声明为字符串并从这些行中删除Const。我不得不用465代替SMTPPort,使用我的SES id / pw,它完美无缺!

相关问题