Google
 

Saturday, September 29, 2012

Tip: Sending email to local folder for ASP.NET local development

Many web applications and sites have features that require sending emails. In production, usually mailSettings element of system.net is configured to send emails using SMTP server.
But when developing on a local machine, you want to check the output email quickly and without relying on a SMTP server. Sometimes a local antivirus can make the process harder.
It's better to configure the mail to send to a local folder, this can be easily done by setting the delivery method to SpecifiedPickupDirectory and setting the local directory location:
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\Temp"/>
</smtp>
</mailSettings>
</system.net>

Now, when your code sends an email, a .eml file will be saved to c:\Temp, and you can double click it to check its content.