Tuesday, January 25, 2005

=3D and = characters in the ASP.NET/MVC HTML emails

Problem:
While trying to send an HTML email from the ASP.NET, you get the junk strange characters in the output.
Eg: 1) appending "3D" (Style type =3D"text/CSS")
2) appending "=" between a two words (cell=padding)
Fix:

Modify the C# code to include the below:
MailMessage message = new MailMessage(SendFrom, SendTo);
var MyplainView = AlternateView.CreateAlternateViewFromString(msgBody,null,"text/html");
MyplainView.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
message.AlternateViews.Add(MyplainView);
message.IsBodyHtml = true;

No comments:

Post a Comment