Yes, I know, it’s been a while since I wrote. There is a LOT of stuff that has gone on, and I may actually put some of it up here.
But… that’s not the reason for this post.
Today, I was racking my brains out trying to find a setting. Well, after a little bit of searching, I found what I was looking for. Since I don’t want to have to chase this information down AGAIN, I thought that I’d post it here 🙂
"What were you looking for?", you ask?
Previously I had seen where the .NET 2.0 SMTP mail classes will allow the mail messages to be redirected to a file. I had thought, "This looks cool. I can use this for testing emails without having to send them." And then, I promptly forgot to do anything with the link. No bookmark, no email, no blog entry, nothing. So, I learned a lesson trying to find that link. 🙂
So, after searching a bit, I ran across Dan Wahlin’s blog entry about ‘Testing Email Messages sent using System.Net.Mail on Windows Vista’. That had the note that I needed!!! Yeah!!! There is a property called DeliveryMethod on the SmtpClient class that controls how email is sent. By setting that property to ‘SpecifiedPickupDirectory’, and then setting the SpecifiedPickupDirectoryLocation. These can be set from code or from the app.config / web.config files. I found another blog post from David Findley about ‘Migrating from System.Web.Mail to System.Net.Mail’. That post also has a little bit of information about threading the email classes.
To send an email to a directory instead of a an SMTP server, here’s the XML to add to a .config file:
<specifiedPickupDirectory pickupDirectoryLocation="C:Temp" />
That’s it! The emails look like the have GUID for a name, with a .eml extension.