【问题标题】:Is there some trick to making VBScript CDO work with Amazon SES SMTP?使 VBScript CDO 与 Amazon SES SMTP 一起工作是否有一些技巧?
【发布时间】:2012-09-30 12:21:29
【问题描述】:

是否有一些技巧可以让 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

【问题讨论】:

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


    【解决方案1】:

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

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

    我不知道你为什么没有得到这个脚本的错误。我愿意。尝试将端口更改为 465。当我将端口更改为 465 时,它可以工作。

    【讨论】:

      【解决方案2】:

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

      将 objMessage 调暗为对象

      另外,由于他使用的是 Const,如果您想更改这些项目中的任何一项,您需要将它们声明为字符串并从这些行中删除 Const。我必须用 465 代替 SMTPPort,使用我的 SES id/pw,它工作得很好!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-08-23
        • 2012-02-23
        • 2022-09-24
        • 1970-01-01
        • 2012-02-13
        • 2018-03-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多