Arquivo da tag: server

Módulo Smtp com modelo de Html

Módulo Smtp com modelo de Html

Módulo Smtp com modelo de Html

Todas as vezes que crio um novo projeto que precisa enviar emails acabo indo atrás de projetos anteriores e faço o famoso ctrl+C, ctrl+V mas recentemente cansei desse hábito horrendo e decidi criar uma biblioteca simples que pode ser referenciada em qualquer projeto.

Caso esteja com pressa, baixe a biblioteca aqui, ou o demo completo aqui.

Página do projeto no Github

Para testar o módulo, use Smtp4Dev.

Para começar, criei a classe que gerencia o SmtpClient e SmtpServer:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Web.Hosting;

namespace Simple_Mail
{
    #region Enums
    /// <summary>
    /// Types of Emails that can be sent
    /// </summary>
    public enum EmailType
    {
        Default,
        Confirmation,
        Forgotten,
        Welcome,
        Error
    }
    /// <summary>
    /// Type of Application this module is being ran from
    /// </summary>
    public enum ApplicationType
    {
        Desktop,
        Web
    }
    #endregion

    #region Class
    /// <summary>
    /// Email Module Class
    /// </summary>
    public class Email
    {
        #region Public Members
        // <summary>
        /// The Email address of the Email Module Admin
        /// </summary>
        public string SITE_ADMIN { get; set; }
        /// <summary>
        /// Subject of the Email
        /// </summary>
        public string SUBJECT { get; set; }
        /// <summary>
        /// Body of the Email (default is html)
        /// </summary>
        public string BODY { get; set; }
        /// <summary>
        /// From Email Address (who's sending the email)
        /// </summary>
        public string FROM { get; set; }
        /// <summary>
        /// From Name (name of who is sending the email)
        /// </summary>
        public string FROM_NAME { get; set; }
        /// <summary>
        /// To Email Address (who is going to receive this email)
        /// </summary>
        public string TO { get; private set; }
        /// <summary>
        /// To Name (name of who is going to receive this email)
        /// </summary>
        public string TO_NAME { get; set; }
        /// <summary>
        /// Username of Smtp Service / Server
        /// </summary>
        public string USERNAME { get; private set; }
        /// <summary>
        /// Password for the smtp service / server
        /// </summary>
        public string PASSWORD { get; private set; }
        /// <summary>
        /// The port number for sending the email address (normal ports are 25, 587, 465)
        /// </summary>
        public int PORT { get; private set; }
        /// <summary>
        /// Whether to use SSL Encryption
        /// </summary>
        public bool USESSL { get; private set; }
        /// <summary>
        /// Uri of the Smtp Server
        /// </summary>
        public string SERVER { get; private set; }
        /// <summary>
        /// Whether the smtp server requires authentication
        /// </summary>
        public bool REQUIREAUTH { get; private set; }
        /// <summary>
        /// Name of the Website or App running the Module
        /// </summary>
        public string WEBSITE_NAME { get; set; }
        /// <summary>
        /// Default Html Body for the Email
        /// </summary>
        public string HTML_DEFAULT { get; private set; }
        /// <summary>
        /// Html body for the Forgotten Email
        /// </summary>
        public string HTML_FORGOTEN { get; private set; }
        /// <summary>
        /// Html Body for the Confirmation Email
        /// </summary>
        public string HTML_CONFIRMATION { get; private set; }
        /// <summary>
        /// Html Body for the Welcome Email
        /// </summary>
        public string HTML_WELCOME { get; private set; }
        /// <summary>
        /// Html for the Social Share
        /// </summary>
        public string HTML_SHARE_PATH { get; private set; }
        /// <summary>
        /// Path for the Default Html File
        /// </summary>
        public string HTML_DEFAULT_PATH { get; private set; }
        /// <summary>
        /// Path for the Forgotten Html File
        /// </summary>
        public string HTML_FORGOTEN_PATH { get; private set; }
        /// <summary>
        /// Path for the Confirmation Html File
        /// </summary>
        public string HTML_CONFIRMATION_PATH { get; private set; }
        /// <summary>
        /// Path for the Welcome Html File
        /// </summary>
        public string HTML_WELCOME_PATH { get; private set; }
        /// <summary>
        /// Path for the Social Share Html File
        /// </summary>
        public string HTML_SHARE { get; private set; }
        #endregion

        #region Constructors
        /// <summary>
        /// Manually configures a Smtp Server Instance (when you do not want to use config files)
        /// </summary>
        /// <param name="smtpServer">The Uri for the smtp server</param>
        /// <param name="smtpPort">The Smtp Port</param>
        /// <param name="useAuth">Whether the Smtp Server Requires Authentication</param>
        /// <param name="username">The Smtp Username</param>
        /// <param name="password">The Smtp Password</param>
        /// <param name="useSSL">Whether to Use SSL Encryption</param>
        public Email(string smtpServer, int smtpPort, bool useAuth = false, string username = "", string password = "", bool useSSL = false)
        {
            SERVER = smtpServer;
            PORT = smtpPort;
            REQUIREAUTH = useAuth;
            USERNAME = username;
            PASSWORD = password;
            USESSL = useSSL;
        }
        /// <summary>
        /// Instanciates a new Email Module based on Config Files and Application Type (Web or Desktop)
        /// </summary>
        /// <param name="type"></param>
        public Email(ApplicationType type)
        {
            switch (type)
            {
                case ApplicationType.Desktop:
                    HTML_CONFIRMATION_PATH = ConfigurationManager.AppSettings["email-html-confirmation"];
                    HTML_WELCOME_PATH = ConfigurationManager.AppSettings["email-html-welcome"];
                    HTML_FORGOTEN_PATH = ConfigurationManager.AppSettings["email-html-forgotten"];
                    HTML_DEFAULT_PATH = ConfigurationManager.AppSettings["email-html-default"];
                    HTML_SHARE_PATH = ConfigurationManager.AppSettings["email-html-share"];
                    break;
                case ApplicationType.Web:
                    HTML_CONFIRMATION_PATH = HostingEnvironment.MapPath(ConfigurationManager.AppSettings["email-html-confirmation"]);
                    HTML_WELCOME_PATH = HostingEnvironment.MapPath(ConfigurationManager.AppSettings["email-html-welcome"]);
                    HTML_FORGOTEN_PATH = HostingEnvironment.MapPath(ConfigurationManager.AppSettings["email-html-forgotten"]);
                    HTML_DEFAULT_PATH = HostingEnvironment.MapPath(ConfigurationManager.AppSettings["email-html-default"]);
                    HTML_SHARE_PATH = HostingEnvironment.MapPath(ConfigurationManager.AppSettings["email-html-share"]);
                    break;
                default:
                    break;
            }


            HTML_CONFIRMATION = GetEmailHtml(HTML_CONFIRMATION_PATH);
            HTML_WELCOME = GetEmailHtml(HTML_DEFAULT_PATH);
            HTML_FORGOTEN = GetEmailHtml(HTML_FORGOTEN_PATH);
            HTML_DEFAULT = GetEmailHtml(HTML_WELCOME_PATH);
            HTML_SHARE = GetEmailHtml(HTML_SHARE_PATH);


            WEBSITE_NAME = ConfigurationManager.AppSettings["WebsiteName"];

            SITE_ADMIN = ConfigurationManager.AppSettings["siteadmin"];

            SERVER = ConfigurationManager.AppSettings["email-server"];
            PORT = int.Parse(ConfigurationManager.AppSettings["email-port"]);
            USESSL = bool.Parse(ConfigurationManager.AppSettings["useSSL"]);
            PASSWORD = ConfigurationManager.AppSettings["email-password"];
            USERNAME = ConfigurationManager.AppSettings["email-username"];
            REQUIREAUTH = bool.Parse(ConfigurationManager.AppSettings["email-require-auth"]);

            TO_NAME = "New " + ConfigurationManager.AppSettings["WebsiteName"] + " Member";
            TO = ConfigurationManager.AppSettings["email-to"];
            FROM_NAME = ConfigurationManager.AppSettings["email-from-name"];
            FROM = ConfigurationManager.AppSettings["email-from"];

            SUBJECT = ConfigurationManager.AppSettings["email-subject"];


        }

        #endregion

        #region Private Members

        private EmailType emailMessageType;
        private string emailMessageHtml;
        private System.Net.Mail.SmtpClient SmtpServer;
        #endregion

        #region Private Methods
        private string GetEmailHtml(string path)
        {
            return File.ReadAllText(path);
        }

        private string GetEmailFilePath(EmailType type)
        {
            emailMessageType = type;

            switch (type)
            {
                case EmailType.Confirmation:
                    emailMessageHtml = HTML_CONFIRMATION;
                    break;
                case EmailType.Forgotten:
                    emailMessageHtml = HTML_FORGOTEN;
                    break;
                case EmailType.Welcome:
                    emailMessageHtml = HTML_WELCOME;
                    break;
                case EmailType.Default:
                    emailMessageHtml = HTML_DEFAULT;
                    break;
                default:
                    emailMessageHtml = "";
                    break;
            }
            return emailMessageHtml;
        }

        private bool SetupServer()
        {
            try
            {
                SmtpServer = new System.Net.Mail.SmtpClient();
                SmtpServer.Port = PORT;
                SmtpServer.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                if (REQUIREAUTH)
                {
                    SmtpServer.UseDefaultCredentials = false;
                    SmtpServer.Credentials = new System.Net.NetworkCredential(USERNAME, PASSWORD);
                }
                else SmtpServer.UseDefaultCredentials = true;

                SmtpServer.Host = SERVER;
                SmtpServer.EnableSsl = USESSL;

                return true;
            }
            catch
            {

                return false;
            }
        }

        #endregion

        #region Public Methods
        /// <summary>
        /// Attempts to send an email
        /// </summary>
        /// <param name="type">The Type of Email Being Sent</param>
        /// <param name="custom">Whether to Customize the email</param>
        /// <param name="body">If customized, set the html body for the email</param>
        /// <param name="To">If customized, defines the TO field</param>
        /// <param name="ToName">If customized, defines the To name</param>
        /// <returns>Returns a KeyValuePair<bool,string> with success (true/false) and a message from the smtp server</returns>
        public KeyValuePair<bool, string> SendMail(EmailType type, bool custom = false, string body = "", string To = "", string ToName = "New Member")
        {

            if (SetupServer())
            {
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

                mail.Subject = SUBJECT;
                mail.From = new System.Net.Mail.MailAddress(FROM, FROM_NAME);
                mail.IsBodyHtml = true;

                if (ToName != "") TO_NAME = ToName;

                if (To == "") mail.To.Add(new System.Net.Mail.MailAddress(TO, TO_NAME));
                else mail.To.Add(new System.Net.Mail.MailAddress(To, TO_NAME));

                if (custom)
                    mail.Body = body;
                else
                {
                    BODY = GetEmailFilePath(type);
                    mail.Body = BODY;
                }

                try
                {
                    SmtpServer.Send(mail);
                    return new KeyValuePair<bool, string>(true, "Email sent succesfully");
                }
                catch (Exception ex)
                {
                    return new KeyValuePair<bool, string>(false, ex.Message);
                }
                finally
                {
                    SmtpServer.Dispose();
                }
            }
            else return new KeyValuePair<bool, string>(false, "Error Setting UP Email");

        }
        /// <summary>
        /// Manually Sets the Body for the Email Message
        /// </summary>
        /// <param name="message">The Html Body for the Email</param>
        public void SetBody(string message)
        {
            BODY = message;
        }
        #endregion

    } 
    #endregion
}

Também inclui algumas configurações no App.Config como modelo, que podem ser usadas no Web.Config caso não queira inserir os dados via código.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <!--email provider section-->
    <add key="siteadmin" value="postmaster@simpleemail.com"/>
    <add key="email-subject" value="Email from Email Website"/>
    <add key="email-from" value="postmaster@puul.ga"/>
    <add key="email-from-name" value="Simple Email"/>
    <add key="email-require-auth" value="false"/>
    <add key="email-username" value="simpleemail"/>
    <add key="email-password" value=""/>
    <add key="email-port" value="3535"/>
    <add key="useSSL" value="false"/>
    <add key="email-server" value="localhost"/>
    <add key="email-html-share" value="~/Email Templates/share.html"/>
    <add key="email-html-default" value="~/Email Templates/default.html"/>
    <add key="email-html-forgotten" value="~/Email Templates/default.html"/>
    <add key="email-html-confirmation" value="~/Email Templates/default.html"/>
    <add key="email-html-welcome" value="~/Email Templates/default.html"/>
  </appSettings>
</configuration>

Mas como também havia interesse em mandar emails em html mais bonitos, usei um modelo do MailChimp™ para ficar mais apresentável. Inclui na pasta de “Email Templates”

<!--MAILCHIMP EMAIL TEMPLATE-->
<!--DON'T CHANGE THE *|VALUES|* AS THEY ARE REPLACED IN THE SERVER - CHANGE THE HTML, TEXT IS AUTOMATICALLY ADDED-->
<td align="center" valign="top" id="bodyCell" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;height: 100%;margin: 0;padding: 10px;width: 100%;border-top: 0;">
    <!-- BEGIN TEMPLATE // -->
						<!--[if gte mso 9]>
						<table align="center" border="0" cellspacing="0" cellpadding="0" width="600" style="width:600px;">
						<tr>
						<td align="center" valign="top" width="600" style="width:600px;">
                          <![endif]-->
                          <table border="0" cellpadding="0" cellspacing="0" width="100%" class="templateContainer" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;border: 0;max-width: 600px !important;">
                            <tbody><tr>
                                <td valign="top" id="templatePreheader" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;background-color: #FAFAFA;border-top: 0;border-bottom: 0;padding-top: 9px;padding-bottom: 9px;"><table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnTextBlock" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                    <tbody class="mcnTextBlockOuter">
                                        <tr>
                                            <td valign="top" class="mcnTextBlockInner" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">

                                                <table align="left" border="0" cellpadding="0" cellspacing="0" width="366" class="mcnTextContentContainer" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                    <tbody><tr>

                                                        <td valign="top" class="mcnTextContent" style="padding-top: 9px;padding-left: 18px;padding-bottom: 9px;padding-right: 0;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;word-break: break-word;color: #656565;font-family: Helvetica;font-size: 12px;line-height: 150%;text-align: left;">

                                                            *|EMAIL_PREVIEW|*
                                                        </td>
                                                    </tr>
                                                </tbody></table>

                                                <table align="right" border="0" cellpadding="0" cellspacing="0" width="197" class="mcnTextContentContainer" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                    <tbody><tr>

                                                        <td valign="top" class="mcnTextContent" style="padding-top: 9px;padding-right: 18px;padding-bottom: 9px;padding-left: 18px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;word-break: break-word;color: #656565;font-family: Helvetica;font-size: 12px;line-height: 150%;text-align: left;">
                                                        </td>
                                                    </tr>
                                                </tbody></table>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table></td>
                            </tr>
                            <tr>
                                <td valign="top" id="templateHeader" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;background-color: #FFFFFF;border-top: 0;border-bottom: 0;padding-top: 9px;padding-bottom: 0;"><table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnImageBlock" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                    <tbody class="mcnImageBlockOuter">
                                        <tr>
                                            <td valign="top" style="padding: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnImageBlockInner">
                                                <table align="left" width="100%" border="0" cellpadding="0" cellspacing="0" class="mcnImageContentContainer" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                    <tbody><tr>
                                                        <td class="mcnImageContent" valign="top" style="padding-right: 9px;padding-left: 9px;padding-top: 0;padding-bottom: 0;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">

                                                            <table style="width: 564px;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcpreview-image-uploader"></table>

                                                        </td>
                                                    </tr>
                                                </tbody></table>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table></td>
                            </tr>
                            <tr>
                                <td valign="top" id="templateBody" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;background-color: #FFFFFF;border-top: 0;border-bottom: 2px solid #EAEAEA;padding-top: 0;padding-bottom: 9px;"><table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnTextBlock" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                    <tbody class="mcnTextBlockOuter">
                                        <tr>
                                            <td valign="top" class="mcnTextBlockInner" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">

                                                <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnTextContentContainer">
                                                    <tbody><tr>

                                                        <td valign="top" class="mcnTextContent" style="padding-top: 9px;padding-right: 18px;padding-bottom: 9px;padding-left: 18px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;word-break: break-word;color: #202020;font-family: Helvetica;font-size: 16px;line-height: 150%;text-align: left;">

                                                            <h1 style="display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 26px;font-style: normal;font-weight: bold;line-height: 125%;letter-spacing: normal;text-align: left;">

                                                                *|HEADER|*

                                                            </h1>

                                                            <p style="margin: 10px 0;padding: 0;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #202020;font-family: Helvetica;font-size: 16px;line-height: 150%;text-align: left;">

                                                                *|FIRSTPARAGRAPH|*
                                                            </p>
                                                            <p style="margin: 10px 0;padding: 0;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #202020;font-family: Helvetica;font-size: 16px;line-height: 150%;text-align: left;">
                                                                *|SECONDPARAGRAPH|*
                                                            </p>
                                                            <p style="margin: 10px 0;padding: 0;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #202020;font-family: Helvetica;font-size: 16px;line-height: 150%;text-align: left;">
                                                                If you need a bit of inspiration, you can 
                                                                <a href="http://inspiration.mailchimp.com" class="mc-template-link" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #2BAADF;font-weight: normal;text-decoration: underline;">
                                                                    see what other MailChimp users are doing
                                                                </a>, or <a href="http://mailchimp.com/resources/email-design-guide/" class="mc-template-link" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #2BAADF;font-weight: normal;text-decoration: underline;">
                                                                learn about email design
                                                            </a> 
                                                            and blaze your own trail.
                                                        </p>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>

                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td valign="top" id="templateFooter" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;background-color: #FAFAFA;border-top: 0;border-bottom: 0;padding-top: 9px;padding-bottom: 9px;"><table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnFollowBlock" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                        <tbody class="mcnFollowBlockOuter">
                            <tr>
                                <td align="center" valign="top" style="padding: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnFollowBlockInner">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnFollowContentContainer" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                        <tbody><tr>
                                            <td align="center" style="padding-left: 9px;padding-right: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnFollowContent">
                                                    <tbody><tr>
                                                        <td align="center" valign="top" style="padding-top: 9px;padding-right: 9px;padding-left: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                            <table align="center" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                <tbody><tr>
                                                                    <td align="center" valign="top" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                    <!--[if mso]>
                                    <table align="center" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <![endif]-->

                                        <!--[if mso]>
                                        <td align="center" valign="top">
                                            <![endif]-->


                                            <table align="left" border="0" cellpadding="0" cellspacing="0" style="display: inline;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                <tbody><tr>
                                                    <td valign="top" style="padding-right: 10px;padding-bottom: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnFollowContentItemContainer">
                                                        <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnFollowContentItem" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                            <tbody><tr>
                                                                <td align="left" valign="middle" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                    <table align="left" border="0" cellpadding="0" cellspacing="0" width="" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                        <tbody><tr>

                                                                            <td align="center" valign="middle" width="24" class="mcnFollowIconContent" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                                <a href="http://www.twitter.com/" target="_blank" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;"><img src="http://cdn-images.mailchimp.com/icons/social-block-v2/color-twitter-48.png" style="display: block;border: 0;height: auto;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;" height="24" width="24" class=""></a>
                                                                            </td>
                                                                            
                                                                            
                                                                        </tr>
                                                                    </tbody></table>
                                                                </td>
                                                            </tr>
                                                        </tbody></table>
                                                    </td>
                                                </tr>
                                            </tbody></table>

                                        <!--[if mso]>
                                        </td>
                                        <![endif]-->

                                        <!--[if mso]>
                                        <td align="center" valign="top">
                                            <![endif]-->


                                            <table align="left" border="0" cellpadding="0" cellspacing="0" style="display: inline;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                <tbody><tr>
                                                    <td valign="top" style="padding-right: 10px;padding-bottom: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnFollowContentItemContainer">
                                                        <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnFollowContentItem" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                            <tbody><tr>
                                                                <td align="left" valign="middle" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                    <table align="left" border="0" cellpadding="0" cellspacing="0" width="" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                        <tbody><tr>

                                                                            <td align="center" valign="middle" width="24" class="mcnFollowIconContent" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                                <a href="http://www.facebook.com" target="_blank" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;"><img src="http://cdn-images.mailchimp.com/icons/social-block-v2/color-facebook-48.png" style="display: block;border: 0;height: auto;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;" height="24" width="24" class=""></a>
                                                                            </td>
                                                                            
                                                                            
                                                                        </tr>
                                                                    </tbody></table>
                                                                </td>
                                                            </tr>
                                                        </tbody></table>
                                                    </td>
                                                </tr>
                                            </tbody></table>

                                        <!--[if mso]>
                                        </td>
                                        <![endif]-->

                                        <!--[if mso]>
                                        <td align="center" valign="top">
                                            <![endif]-->


                                            <table align="left" border="0" cellpadding="0" cellspacing="0" style="display: inline;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                <tbody><tr>
                                                    <td valign="top" style="padding-right: 0;padding-bottom: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnFollowContentItemContainer">
                                                        <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnFollowContentItem" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                            <tbody><tr>
                                                                <td align="left" valign="middle" style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 9px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                    <table align="left" border="0" cellpadding="0" cellspacing="0" width="" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                        <tbody><tr>

                                                                            <td align="center" valign="middle" width="24" class="mcnFollowIconContent" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                                                                                <a href="http://mailchimp.com" target="_blank" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;"><img src="http://cdn-images.mailchimp.com/icons/social-block-v2/color-link-48.png" style="display: block;border: 0;height: auto;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;" height="24" width="24" class=""></a>
                                                                            </td>
                                                                            
                                                                            
                                                                        </tr>
                                                                    </tbody></table>
                                                                </td>
                                                            </tr>
                                                        </tbody></table>
                                                    </td>
                                                </tr>
                                            </tbody></table>

                                        <!--[if mso]>
                                        </td>
                                        <![endif]-->

                                    <!--[if mso]>
                                    </tr>
                                    </table>
                                    <![endif]-->
                                </td>
                            </tr>
                        </tbody></table>
                    </td>
                </tr>
            </tbody></table>
        </td>
    </tr>
</tbody></table>

</td>
</tr>
</tbody>
</table><table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnDividerBlock" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;table-layout: fixed !important;">
<tbody class="mcnDividerBlockOuter">
    <tr>
        <td class="mcnDividerBlockInner" style="min-width: 100%;padding: 10px 18px 25px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
            <table class="mcnDividerContent" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width: 100%;border-top-width: 2px;border-top-style: solid;border-top-color: #EEEEEE;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                <tbody><tr>
                    <td style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
                        <span></span>
                    </td>
                </tr>
            </tbody></table>
<!--            
                <td class="mcnDividerBlockInner" style="padding: 18px;">
                <hr class="mcnDividerContent" style="border-bottom-color:none; border-left-color:none; border-right-color:none; border-bottom-width:0; border-left-width:0; border-right-width:0; margin-top:0; margin-right:0; margin-bottom:0; margin-left:0;" />
            -->
        </td>
    </tr>
</tbody>
</table><table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnTextBlock" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
<tbody class="mcnTextBlockOuter">
    <tr>
        <td valign="top" class="mcnTextBlockInner" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">

            <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnTextContentContainer">
                <tbody><tr>

                    <td valign="top" class="mcnTextContent" style="padding-top: 9px;padding-right: 18px;padding-bottom: 9px;padding-left: 18px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;word-break: break-word;color: #656565;font-family: Helvetica;font-size: 12px;line-height: 150%;text-align: center;">

                        <em>Copyright &copy; *|CURRENT_YEAR|* *|LIST:COMPANY|*, All rights reserved.</em>
                        <br>
                        <br>
                        <br>

                    </td>
                </tr>
            </tbody></table>

        </td>
    </tr>
</tbody>
</table></td>
</tr>
</tbody></table>
						<!--[if gte mso 9]>
						</td>
						</tr>
						</table>
						<![endif]-->
                        <!-- // END TEMPLATE -->
                    </td>

Para usar o módulo, instancia-se desta forma

            Email _email = new Email(ApplicationType.Web);
            string defaultHtml = _email.HTML_CONFIRMATION;
            string body = defaultHtml
                .Replace("*|EMAIL_PREVIEW|*", "This is a Simple Email")
                .Replace("*|HEADER|*", "Simple Email Website")
                .Replace("*|FIRSTPARAGRAPH|*", "The message below has been customized")
                .Replace("*|SECONDPARAGRAPH|*", Message)
                .Replace("*|WEBSITE_URL|*", Request.Url.ToString())
                .Replace("*|WEBSITE_NAME|*", _email.WEBSITE_NAME)
                .Replace("*|CURRENT_YEAR|*", DateTime.Now.Year.ToString());


            _email.SendMail(EmailType.Confirmation, true, body, Email);

Basicamente, está criado um módulo que pode ser reusado em outros projetos, sem o horrendo copy/paste. Claro, melhorias sempre podem ser feitas, por isso o projeto é open source e pode ser baixado do Github.

Para testar a funcionalidade, recomendo usar Smtp4Dev que é bastante prático e não requer nem instalação.