title: c# mail script failing on HTML content
body: <p>I'm putting together a script to send out a preview html mail to hotmail etc, and I utlising an existing script - I'm new to c# so this is as much a learning expereince forme too.</p>
  
  <p>The problem is I have made a few ammends, and it's fine up to the point I drop HTML source into the comments box - it then fails the sending.</p>
  
  <p>I have looked into it and tried changing the new MailMessage(); to new MailDefinition(); and also adding in faqMsg.IsBodyHtml = true; but it's still failing. it's fine just on regular text. Any thoughts what I need to look into ?</p>
  
  <pre><code>SmtpClient smtpCli = new SmtpClient("localhost");
  MailMessage faqMsg = new MailMessage();
  //MailDefinition faqMsg = new MailDefinition();
  
  //faqMsg.BodyFileName = "email.htm";  
  //faqMsg.IsBodyHtml = true;
  faqMsg.From = new MailAddress("");
  faqMsg.To.Add("");
  faqMsg.Subject = "Mail test :" + subject.Text;
  
  //Plain Text part
  AlternateView plainView = AlternateView.CreateAlternateViewFromString("Enquiry Type:" + enquirytype.SelectedValue + "\r\nFrom:" + "\r\nEmail:" + email.Text + "\r\n\r\nComments\r\n" + comments.Text + "\r\n[EOF]", null, "text/plain");
  //HTML part
  
  AlternateView htmlView = AlternateView.CreateAlternateViewFromString("&lt;strong&gt;Enquiry Type:&lt;/strong&gt;" + enquirytype.SelectedValue + "&lt;br&gt;&lt;br&gt;&lt;strong&gt;Email:&lt;/strong&gt;" + email.Text + "&lt;br&gt;&lt;br&gt;&lt;hr&gt;&lt;br&gt;&lt;strong&gt;Comments&lt;/strong&gt;&lt;br&gt;" + HttpUtility.HtmlEncode(comments.Text) + "&lt;br&gt;EOF", null, "text/html");
  faqMsg.AlternateViews.Add(plainView);
  faqMsg.AlternateViews.Add(htmlView);
  
  //Add Header Markers
  faqMsg.Headers.Add("X-Company", "");
  faqMsg.Headers.Add("X-Location", "");
  faqMsg.Headers.Add("X-Brand", "");
  
  smtpCli.Send(faqMsg);
  lbReport.Text = "Your Message was Sent";
  //Response.Redirect("email-thanks.aspx");
  </code></pre>