title: c# sending html email template include css not working
body: <p>i trying to send html email template, it works perfect, but when i put css internal styles it gives error : input string was not in correct format,</p>
  
  <p>my html template that works good:</p>
  
  <pre><code>&lt;h3&gt;data&lt;/h3&gt;
  &lt;hr /&gt;
  &lt;table class="table table-striped table-bordered table-advance table-hover"&gt;
      &lt;tr&gt;
          &lt;td&gt;data &lt;/td&gt;
          &lt;td&gt;{0}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data &lt;/td&gt;
          &lt;td&gt;{1}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{2}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{3}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{4}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{5}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{6}&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>my html template that gives  Input string was not in a correct format error : </p>
  
  <pre><code>&lt;h3&gt;data&lt;/h3&gt;
  &lt;hr /&gt;
  &lt;table class="table table-striped table-bordered table-advance table-hover"&gt;
      &lt;tr&gt;
          &lt;td&gt;data &lt;/td&gt;
          &lt;td&gt;{0}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data &lt;/td&gt;
          &lt;td&gt;{1}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{2}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{3}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{4}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{5}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;data&lt;/td&gt;
          &lt;td&gt;{6}&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;style type="text/css"&gt;
      table td{border:solid 1px;}
  &lt;/style&gt;
  </code></pre>
  
  <p>my c# code that read and send: </p>
  
  <pre><code>C_GeneralSettings settings = db.C_GeneralSettings.SingleOrDefault();
  S_ResidencesReservations item = db.S_ResidencesReservations.SingleOrDefault(x =&gt; x.ReserveId == entity.ReserveId);
  string subject = "data";
  string message = System.IO.File.ReadAllText(Server.MapPath("~/EmailTemplates/ReservationDetails.html"));
  message = string.Format(message, entity.ReserveId, entity.IsApproved ? "yes" : "no", entity.PayementPeriodEndDate, entity.ReservationDate.ToString("MM/dd/yyyy"), entity.Name, entity.Email, entity.CellPhone);
  
  HelperMethods.SendEmail(message, entity.Email, subject, settings);
  </code></pre>
  
  <p>and my send mail method:</p>
  
  <pre><code>public static void SendEmail(string messageContent, string toEmail, string subject, C_GeneralSettings emailEntity)
  {
      //Check if email service is allowed
      bool allowEmailService = emailEntity.AllowEmailService;
      if (!allowEmailService)
          return;
  
      //Construct mail message
      string from = emailEntity.Email;
      string displayName = emailEntity.DisplayName;
      string to = toEmail;
  
      MailMessage message = new MailMessage();
      message.From = new MailAddress(from, displayName);
      message.To.Add(new MailAddress(to));
      message.Subject = subject;
      message.IsBodyHtml = true;
      message.Body = messageContent;
  
      //Get mail settings from config file
      string host = emailEntity.Host;
      string username = emailEntity.Email;
      string password = emailEntity.Password;
      int port = emailEntity.Port;
      bool enableSsl = emailEntity.EnableSSL;
  
      //Send the message
      SmtpClient smtp = new SmtpClient();
      smtp.Host = host;
      smtp.Port = port;
      smtp.Credentials = new System.Net.NetworkCredential(username, password);
      smtp.EnableSsl = enableSsl;
  
      smtp.Send(message);
  }
  </code></pre>