2012-10-10 55 views
5

VBScript CDOをAmazon SES SMTPと連携させるためのいくつかのトリックはありますか?私は何の誤りもありませんが、それは私に私のテスト電子メールを送っていません。 SSLをFalseに変更すると530エラーが発生するため、少なくともサーバーに到達しています。私は間違って何をしていますか?VBScript CDOをAmazon SES SMTPと連携させるためのいくつかのトリックはありますか?

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 = "[email protected]" 
Const EmailFromName = "Me Test" 
Const EmailTo = "[email protected]a.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 

答えて

7

CDOはTLSをサポートせず、SSLのみをサポートします。 AWS SESでは、TCPポート465でSSLを使用できます。投稿したスクリプトのようにポート25でSSLを使用しようとすると、次のエラーメッセージが返されます。

CDO.Message.1:サーバー。

このスクリプトでこのエラーが発生しない理由はわかりません。私がやります。ポートを465に変更してください。ポートを465に変更すると動作します。

0

これは素晴らしいルーチンです。彼はのConstを使用しているので、これらの項目のいずれかを変更したい場合は、文字列としてそれらを宣言し、削除する必要があります、

薄暗いobjMessageをObjectとして

また:あなたはオブジェクトとしてobjMessageを宣言する必要がありますこれらの行からConst。私はSMTPPortの代わりに465を使用しなければなりませんでした。私のSES ID/pwを使用してください。

関連する問題