Don't be a spammer!

If you are like me, you are always required to make your applications allow the user to complete task and processes. Of course, as humans we always want confirmation when we do something. If we buy something, we want a receipt. Same is true for processes in software. I submit an order at Amazon.com, I want an E-Mail confirming my order, then an E-mail when my order ships with the shipping tracking number.
This is no different than for any software I have had to write. One problem I have during development is that I don’t want to start sending out emails all over the dang place nor really want to access the only mail server available to me – my work Exchange server. The guys in IT hate it when you are testing something, accidently make an infinite loop and send out 10,000 test E-Mails before you realize “oops!”
Well, I came across a way to use configuration setting in a ASP.NET web app (I don’t see why this wouldn’t work in a winform app either). In your web.config add the following in your system.net / mailSettings section

<smtp deliveryMethod="SpecifiedPickupDirectory">
<network host="ignored"/>
<specifiedPickupDirectory pickupDirectoryLocation="c:\temp"/>
</smtp>

Now, in your code where you plan to send your System.Net.Mail.MailMessage , do this:

new SmtpClient().SendMailMessage(MyMailMessage);

Once you do this, if you go look in the pickupDirectoryLocation folder, you will see your mail message as an .eml file.
You can open the message and check to make sure it is correct without becoming a local spammer!

Comments

Popular posts from this blog

It is on like Donkey Kong!

Open Letter to Microsoft

Writing a Video Game