dirq.net

the life and work of dirk watkins

September 28, 2011
by Dirk
0 comments

Testing Email from Local Apps with a Pickup Directory

I just learned about this neat trick that’s helpful for developing email features locally.

In your web.config file you can tell your application to save emails to a folder instead of sending through an smtp server.  This way you can have your application code work as normal and check all the emails it sends by just looking in a folder.  The folder has to exist first.  For instance, I created a local folder called c:TempEmail and then changed my local web.config to this:

<!--
<system.net>
<mailSettings>
<smtp from="email@address.com">
<network host="smtp.address.com" password="" userName="" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>
-->

<!-- use a pickup directory for debugging -->

<system.net>
<mailSettings>
<smtp from="email@address.com" deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:TempEmail"/>
</smtp>
</mailSettings>
</system.net>

All email sent through your application will end up as a file in the c:TempEmail folder instead of actually being sent out. And I didn’t have to change my code at all!

MailDefinition md = new MailDefinition();
...
MailMessage msg = md.CreateMailMessage(user.Email, replacements, bodyHtml, newSystem.Web.UI.Control());

//send it!
SmtpClient smtp = new SmtpClient();
smtp.Send(msg);

You can open the eml file in Outlook and it’ll look just like it’ll look in the real world – except that you didn’t bother your user with a test email.  Sweet!

April 30, 2010
by Dirk
0 comments

Fighting Multiple Sclerosis with Music

Take Solace, Wolfgang Schaefer, MBird and Bryan Cherry will be playing a benefit to help raise money for MS research. The event will be at the Art Bar on 4/30/2010.  Music starts around 8:30pm.  Take Solace will most likely play around 11.

Rock to Challenge MS (Art Bar)
Milwaukee, WI
8:00pm
Suggested Donation of $10
722 E. Burleigh St., Milwaukee, WI
Venue phone: 414.372.7880

See the Facebook page for details (login required):
http://www.facebook.com/event.php?eid=298793726834