title: Adding css in html that will be sent to an email
body: <p>I have created a method that will send an email with information to customers. However, the email looks awful cus there is no style to it. I can't apply the style to the email for some reason. I have tried to google it, and there is a lot on how to solve this in code behind, but that's not my issue. I must place the css code in the Html body, since it must be displayed for the client when he opens the email. </p>
  
  <p>So my question is, how do I add css to the html code above? I have tried doing: </p>
  
  <pre><code>&lt;div style='...'&gt;&lt;/div&gt;
  </code></pre>
  
  <p>and this does not work</p>
  
  <p>Any help on how to solve this is appreciated. Below some of my code. I have shortened it, for readability.</p>
  
  <pre><code>string HtmlBody = @"&lt;div style='float: right'&gt;
      &lt;h3&gt;Faktura&lt;/h3&gt; &lt;br /&gt;
      Navn:&lt;asp:Label ID='navn' runat='server' Text='%Navn%'/&gt; &lt;br /&gt;
      Adresse:&lt;asp:Label ID='adresse' runat='server' Text='%Adresse%'/&gt; &lt;br /&gt;
      Postnr:&lt;asp:Label ID='postnummer' runat='server' Text='%Postnr%'/&gt; &lt;br /&gt;
      Land:&lt;asp:Label ID='land' runat='server' Text='Danmark' /&gt; &lt;br /&gt;
      Tlf: &amp;nbsp;&lt;asp:Label ID='tlfnummer' runat='server' Text='%Tlf%' /&gt; &lt;br /&gt;
      Mail: &amp;nbsp;&lt;asp:Label ID='email' runat='server' Text='%Email%' /&gt; &lt;br /&gt;
  
      &lt;div style='float: right'&gt;
          &lt;p&gt;Dato&lt;/p&gt;                                 
      &lt;/div&gt; 
      &lt;hr /&gt; &lt;br /&gt;
      &lt;table style='background-color: #c00764'&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Fakturanr:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;%fakturanr%&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Ordrenr:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;%Ordrenr%&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;";
  </code></pre>
  
  <p>Here are some of my info on the mail part</p>
  
  <pre><code>MailMessage mailMsg = new MailMessage();
  mailMsg.IsBodyHtml = true;
  mailMsg.Priority = MailPriority.Normal;
  
  var smtpValues = GetSmtpValues();
  var smtpCredentials = GetNetworkCredentials();
  
  SmtpClient smptClient = new SmtpClient(smtpValues.Key, smtpValues.Value);
  smptClient.EnableSsl = true;
  smptClient.Credentials = new NetworkCredential(smtpCredentials.Key, smtpCredentials.Value);
  
  //Send mail
  smptClient.Send(mailMsg);
  </code></pre>