Nice to remember the little things

When a fellow developer came over to talk about sending an email from his tool and I had forgotten this little hat trick.  When you need to pop up an email in the event your software needed to send you some information (such as an unhandled exception), you can use something like this handy little tool.

public static void CreateEmail(string _to, string _subject,
    string _body = “”,
    string _cc = “”,
    string _bcc = “”)
{
    StringBuilder mailTo = new StringBuilder();
    mailTo.Append(“mailTo:”).Append(_to);
    mailTo.Append(“&subject=”).Append(_subject);

    if (!String.IsNullOrEmpty(_body)) mailTo.Append(“&body=”).Append(_body);
    if (!String.IsNullOrEmpty(_cc)) mailTo.Append(“&CC=”).Append(_cc);
    if (!String.IsNullOrEmpty(_bcc)) mailTo.Append(“&BCC=”).Append(_bcc);

    Process.Start(mailTo.ToString());
}

Happy Coding!
Advertisements

About JohnMarkHowell

I am a professional software developer with over 20 years of experience. I currently specialize in Microsoft technologies such as VS, TFS, C#, VB.Net, WCF, WPF, WW, etc.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s