ASP CDO with Amazon SES

I am trying to move a script that uses CDO over from using mail relay to using Amazon SES service.

The code was working previously with SMTP, but the configuration of was set to allow all requests from the web server IP that the code is sitting on.  With Amazon SES this isnt possible and you have to authenticate.  SES doesnt allow anything but SSL/TLS connections, hence why i think its failing.

The code is:

Set Mail = CreateObject("CDO.Message")

    Mail.Configuration.Fields.Item("")= 2
    Mail.Configuration.Fields.Item("")= ""
    Mail.Configuration.Fields.Item("")= 465
    Mail.Configuration.Fields.Item("") = 1
    Mail.Configuration.Fields.Item("") = 60
    Mail.Configuration.Fields.Item("") = 1
    Mail.Configuration.Fields.Item("") ="un"
    Mail.Configuration.Fields.Item("") ="pw"

    'update the configuration options
	Mail.From = ""
	Mail.To = strSendTo
	Mail.Bcc = Bcc
	Mail.Cc = Cc
	Mail.Subject = strSubject 
		IF BodyFormat = 1 THEN
			Mail.TextBody = strMessage
		ELSEIF BodyFormat = 0 THEN
			Mail.HtmlBody = strMessage
Set Mail = Nothing

Open in new window

If i use the code above, it fails with:

error '80040211'
/pages/processing/process_let_us_contact.asp, line 36

Any idea how i can get ASP classic to work with AWS SES?

I have tried switching to port 25 and the problem is the same.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
What you have looks good.  Are you 100% sure you have AWS SES set up correctly? Paid etc?

I have used sendgrid for this type of thing and  now mandrill.  Mandrill is free for the first 11,000 monthly emails and I would suggest using this or sendgrid for better deliverability.

This is what I use for mandrill
theHtml = "<table>full email html</table>"

' Set stuff up here
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
'SMTP userinfo

unsubscribeHTML ="<div>This email newsletter is only sent to our students and friends.   If you no longer wish to receive these emails, please click the remove me link.  <a href=""*|UNSUB:|*"">Click here to unsubscribe.</a></div>"


Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = theSubject 
objMessage.From = "News <>"
objMessage.To = ""&(rsEmailList.Fields.Item("FirstName").Value)&" "&(rsEmailList.Fields.Item("LastName").Value)&" <"&rsEmailList.Fields.Item("Email").Value&">"'Rcpt
objMessage.HTMLBody =  theHtml' runs sub EmailBody

'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item _
("") = 2 
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("") =  "" 
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("") = smtpUser
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("") = smtpPass
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("") = 465 
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("") = true
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("") = 60

'==End remote SMTP server configuration section==


Open in new window

It is important to note that I have also set up dkim and spf records.  And that may be something you are missing in AWS.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I also  use this site as my reference

Another options is to use the aws api

You can simply use xmlhttppost to send the data
Date: Thu, 18 Aug 2011 22:25:27 GMT
Content-Type: application/x-www-form-urlencoded
X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE,
 Algorithm=HmacSHA256, SignedHeaders=Date;Host
Content-Length: 230


Open in new window

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
One last option that I have resorted to is to use an sdk that already exits like php.  Then set up a php page to do the work for you as your own web service where you can post data to via classic asp xmlhttpost.  It can be a lot easier than trying to program the long way in classic asp.
$result = $client->sendEmail(array(
    // Source is required
    'Source' => 'string',
    // Destination is required
    'Destination' => array(
        'ToAddresses' => array('string', ... ),
        'CcAddresses' => array('string', ... ),
        'BccAddresses' => array('string', ... ),
    // Message is required
    'Message' => array(
        // Subject is required
        'Subject' => array(
            // Data is required
            'Data' => 'string',
            'Charset' => 'string',
        // Body is required
        'Body' => array(
            'Text' => array(
                // Data is required
                'Data' => 'string',
                'Charset' => 'string',
            'Html' => array(
                // Data is required
                'Data' => 'string',
                'Charset' => 'string',
    'ReplyToAddresses' => array('string', ... ),
    'ReturnPath' => 'string',

Open in new window

net-workxAuthor Commented:
Sorry for the delay - accepted this cannot be done natively and switched to mandrill.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.