Html body with .Net

Discussion regarding the Standard version.
Post Reply
cesarqz86
Posts: 1
Joined: Fri Feb 28, 2014 12:16 am

Html body with .Net

Post by cesarqz86 » Fri Feb 28, 2014 12:21 am

Hi guys,

I need help, I'm trying to send an email with a HTML body, but always the mail arrived as a plain text, this is my code:

mailMessage.From = from;
mailMessage.To.Add(to);
mailMessage.Subject = subject;
AlternateView alternate = AlternateView.CreateAlternateViewFromString(message, new ContentType("text/html"));
mailMessage.AlternateViews.Add(alternate);
mailMessage.IsBodyHtml = true;
mailMessage.Priority = MailPriority.High;
server.Send(mailMessage);

And this is my HTML message:


<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<HTML>
<HEAD>
<META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">
<LINK rel=\"stylesheet\" type=\"text/css\" media=\"screen\" charset=\"utf-8\" href=\"{0}\">
</HEAD>
<BODY>
<DIV align=\"center\">
<DIV class=\"DIVImageMail\">
<DIV align=\"center\" class=\"DIVContentText\">
<P class=\"contentText\">
<span class=\"contentName\">
Hi {1},
</span>
Best Regards<br />
</P>
</DIV>
</DIV>
</DIV>
</BODY>
</HTML>

Post Reply