ASP.NET SMTP – Setting a Pickup Directory for Development

3rd August 2009

One of the hidden gems of System.Net is the ability to change from using an SMTP server for sending your email. Instead you can specify a pickup directory which will receive all emails sent from your application as a .EML text file. There are clearly uses for this in production – you may have a second application which monitors this pickup directory and sends the emails after performing some processing on them.

My favourite use of this feature is for development – when you’re sending loads of test emails you can avoid polluting your inbox and simply check the pickup directory. You also avoid having to set up an SMTP host and all of the associated configuration.

Simply add the following to your web.config’s section:

 <smtp deliveryMethod="SpecifiedPickupDirectory">
 <specifiedPickupDirectory pickupDirectoryLocation="c:temp"/>

Make sure you’ve got the right permissions on the directory. Now, send an email from your application and watch it appear in c:temp, as if by magic!

Got an idea for a project?

Need a website? Web-enabled software to streamline your business? Just some advice? A hug?