Friday, November 17, 2006

When you're developing and testing your system, you'll want to test that any emails sent are actually being sent to the SMTP server correctly: the html format is all ok; email from and email to are correct; etc.

 

An easy way to do this is by configuring .NET to drop the emails you send to a specific folder. As long as you’re sending your emails via SmtpClient and are configuring it via the web.config file (if not, why not?), the following configuration section will set up the email folder:

<system.net>
   <mailSettings>
      <smtp deliveryMethod="SpecifiedPickupDirectory">
         <specifiedPickupDirectory pickupDirectoryLocation="C:\Temp\EmailPickupFolder"/>
      </smtp>
   </mailSettings>
</system.net>

If you then browse to the folder, you’ll see files like below. When opened in notepad, you’ll see the email in it’s raw format, or if you need to check any Html formatting, you can open it in Outlook Express.

 

Notepad View

Outlook Express View

Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):