title: Problem sending email with SmtpClient in C#
body: <p>I have an ASP.Net/MVC application and I'm trying to send HTML emails.  I'm doing this by reading in an HTML file with tokens, then replacing the tokens.  That part is fine and generates HTML that is exactly what I want, but when I send the email, what I'm receiving looks like -</p>
  
  <pre><code>&lt;style type=3D"text/css"&gt;=
  =0D=0A.styleTitles=0D=0A{=0D=0Afont-weight:=bold;=0D=0A}=0D=0A 
  .style1=0D=0A        {=0D=0A 
  </code></pre>
  
  <p>and should look like</p>
  
  <pre><code>    &lt;style type="text/css"&gt;
      .styleTitles
      {
          font-weight: bold;
      }
      .style1
      {
          height: 15px;
      }
  </code></pre>
  
  <p>I've looked on the web and I can't seem to find the correct syntax to send the message.  I've seen some solutions, but none seem to work.</p>
  
  <p>My current test code is -</p>
  
  <pre><code>SmtpClient smtpclient = new SmtpClient();
  MailMessage message = new MailMessage();
  
  MailAddress SendFrom = new MailAddress("xxxx@abc.com");
  MailAddress SendTo = new MailAddress("zzzz@gmail.com");
  MailMessage MyMessage = new MailMessage(SendFrom, SendTo);
  
  var plainView = AlternateView.CreateAlternateViewFromString(msgBody,null,"text/html");
  plainView.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
  MyMessage.AlternateViews.Add(plainView);
  MyMessage.IsBodyHtml = true;
  MyMessage.Subject = subjectLine;
  MyMessage.Body = msgBody;
  smtpclient.Send(MyMessage);
  </code></pre>
  
  <p>Any Suggestions?</p>