VS.NET 2010 (and above) Users Click Here   

HOMECONTACT PRODUCTS DOWNLOADS PURCHASE TESTIMONIALS FORUMS COMPANY CONTACT
Home
Products
Downloads
Purchase
Licensing
Licensing FAQ
Software Updates
Support Forums
Testimonials
Feature Requests
Guarantee
About Us
Contact Us
Hosting Companies
Privacy Policy
   
Shopping Cart



aspNetEmail Supports Amazon Simple Email Service

by Dave 2. April 2011 18:33

aspNetEmail now supports the recently launched Amazon Simple Email Service.

Amazon Simple Email Service (Amazon SES) is a highly scalable and cost-effective bulk and transactional email-sending service for businesses and developers. Amazon SES eliminates the complexity and expense of building an in-house email solution or licensing, installing, and operating a third-party email service.

You can read more about the service here:
http://aws.amazon.com/ses/

Once you have signed up for the service, you will receive 2 keys from Amazon. The are an Access Key and a Secret Key.

The Access Key identifies who you are, when you make a web request to the amazon SES.

The Secret key is used to sign your request, to verify your identity.

Once you have these 2 keys, you need to first verify an email address you can used as a sender and a recipient of email.  Here is some code on how to do this:

[C#]

//create the Simple Email Service object
Ses ses =new Ses();

//create an EmailMessage object
EmailMessage msg = new EmailMessage();		

//enable logging for any troubleshooting purposes
msg.LogPath = "c:\\temp\\email.log";
msg.Logging = true;

ses.EmailMessage = msg;

//a method that fetches the Aws secret key
//the secret key will look something like BtasdfuKAEWasdfs701j2DLDFM
ses.SecretKey = AwsSecretKey();

//a method that fetches the Aws access key. 
//The access key will look something like AKIUOASDFU82PT36BA
ses.AccessKey = AwsAccessKey();

//Verify an email address
SesResponse  resp = ses.VerifyEmailAddress("test@example.com");

if( resp.ErrorString != null )
{	
	//an error occurred, write out the error message 
	Response.Write( HttpUtility.HtmlEncode( resp.ErrorString ));
}
else
{
	//Success
	//Write out the result string from Amazon
	Response.Write( HttpUtility.HtmlEncode(resp.ResultString ));			
}

[VB.NET]

'create the Simple Email Service object
Dim ses As New Ses()

'create an EmailMessage object
Dim msg As New EmailMessage()

'enable logging for any troubleshooting purposes
msg.LogPath = "c:\temp\email.log"
msg.Logging = True

ses.EmailMessage = msg

'a method that fetches the Aws secret key
'the secret key will look something like BtasdfuKAEWasdfs701j2DLDFM
ses.SecretKey = AwsSecretKey()

'a method that fetches the Aws access key. 
'The access key will look something like AKIUOASDFU82PT36BA
ses.AccessKey = AwsAccessKey()

'Verify an email address
Dim resp As SesResponse = ses.VerifyEmailAddress("test@example.com")

If Not (resp.ErrorString Is Nothing) Then
   'an error occurred, write out the error message 
   Response.Write(HttpUtility.HtmlEncode(resp.ErrorString))
Else
   'Success
   'Write out the result string from Amazon
   Response.Write(HttpUtility.HtmlEncode(resp.ResultString))
End If

Once you have verified your email address, you will receive an email from Amazon, containing a verification link. This link simply verifies you have access to the account you are validating. You can also verify additional email addresses.

Once you have the email addresses verified, you can now start sending email.

Below is a code example that demonstrates this.

[C#]

//create the Simple Email Service object
Ses ses =new Ses();

//create an EmailMessage object
EmailMessage msg = new EmailMessage();		

//enable logging for any troubleshooting purposes
msg.LogPath = "c:\\temp\\email.log";
msg.Logging = true;

//set the FROM and TO addresses
msg.From = "me@example.com";
msg.AddTo("you@example.com" );

//various other properties
msg.Body = "this is an amazon test";		
msg.Subject = "amazon test";

ses.EmailMessage = msg;

//a method that fetches the Aws secret key
//the secret key will look something like BtasdfuKAEWasdfs701j2DLDFM
ses.SecretKey = AwsSecretKey();

//a method that fetches the Aws access key. 
//The access key will look something like AKIUOASDFU82PT36BA
ses.AccessKey = AwsAccessKey();

//Send the Parent EmailMessage
SesResponse  resp = ses.SendWithResponse();

if( resp.ErrorString != null )
{	
	//an error occurred, write out the error message 
	Response.Write( HttpUtility.HtmlEncode( resp.ErrorString ));
}
else
{
	//Success
	//Write out the result string from Amazon
	Response.Write( HttpUtility.HtmlEncode(resp.ResultString ));			
}

[VB.NET]

'create the Simple Email Service object
Dim ses As New Ses()

'create an EmailMessage object
Dim msg As New EmailMessage()

'enable logging for any troubleshooting purposes
msg.LogPath = "c:\temp\email.log"
msg.Logging = True

'set the FROM and TO addresses
msg.From = "me@example.com"
msg.AddTo("you@example.com" )

'various other properties
msg.Body = "this is an amazon test"		
msg.Subject = "amazon test"

ses.EmailMessage = msg

'a method that fetches the Aws secret key
'the secret key will look something like BtasdfuKAEWasdfs701j2DLDFM
ses.SecretKey = AwsSecretKey()

'a method that fetches the Aws access key. 
'The access key will look something like AKIUOASDFU82PT36BA
ses.AccessKey = AwsAccessKey()

'Send the Parent EmailMessage
Dim resp As SesResponse = ses.SendWithResponse()

If Not (resp.ErrorString Is Nothing) Then
   'an error occurred, write out the error message 
   Response.Write(HttpUtility.HtmlEncode(resp.ErrorString))
Else
   'Success
   'Write out the result string from Amazon
   Response.Write(HttpUtility.HtmlEncode(resp.ResultString))
End If

That's all there is too it. Currently this functionality is in Beta of the EmailMessage object, but it will be in production mode in Version 4.0 of aspNetEmail. If you would like a beta version of this, feel free to contact us, using the Contact Us page, and request the Amazon Ses beta.

As always, if you have any questions, comments, or feedback, let me know.

Thanks!
Dave

Comments are closed

 

 

ListNanny aspNetDNS aspNetEmail aspNetPOP3 aspNetMX IPMuncher aspNetMIME aspNetPING aspNetTraceRoute aspNetIMAP aspNetMHT