Generic Send mail method

Here is a generic send mail method.

You just need to pass in a subject and body.
In your web.config you need a key for the from (notification_from), To (notification_to) and mail server (mail_server).
You could easily alter it to move the to (or from) to input variables.

private static void sendNotification(String Subject, String Body)
            MailMessage mailMessage = new MailMessage();
            SmtpClient smtpClient = new SmtpClient();
            string msg = string.Empty;

            String from = ConfigurationManager.AppSettings["notification_from"];
            String to = ConfigurationManager.AppSettings["notification_to"];
            String mailserver = ConfigurationManager.AppSettings["mail_server"];

            MailAddress fromAddress = new MailAddress(from);
            mailMessage.From = fromAddress;
            mailMessage.Subject = Subject;
            mailMessage.IsBodyHtml = true;
            mailMessage.Body = Body;

            smtpClient.Host = mailserver;

            smtpClient.EnableSsl = false;
            smtpClient.UseDefaultCredentials = true;

[tweetmeme only_single=”false”]