I have a form which when illed and submitted sends an email in HTML format. Some times I get the email with HTML tags in them. Can anyone please help me out on how to overcome this problem.
Well, start out by posting your code so we can see what you are doing. Then we should be able to help you. Otherwise, we are only speculating which won't be much help to you.
This is the code i used to generate the HTML email. I get tags in the email. Not always but sometimes and not all the errors are same. Eeach time I get a tag at different place and sometimes i don't.
Sometimes however the client may not be capable of displaying formatted HTML which renders as plain text. Check one of the client programs that is doing this to see if emails received are converted to plain text.
praveen13788
Member
8 Points
43 Posts
Problem with HTML tags
Dec 27, 2012 04:59 PM|LINK
Hello all,
I have a form which when illed and submitted sends an email in HTML format. Some times I get the email with HTML tags in them. Can anyone please help me out on how to overcome this problem.
Regards,
bbcompent1
All-Star
32994 Points
8509 Posts
Moderator
Re: Problem with HTML tags
Dec 27, 2012 05:54 PM|LINK
Well, start out by posting your code so we can see what you are doing. Then we should be able to help you. Otherwise, we are only speculating which won't be much help to you.
praveen13788
Member
8 Points
43 Posts
Re: Problem with HTML tags
Dec 27, 2012 06:38 PM|LINK
"<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" + "<html xmlns='http://www.w3.org/1999/xhtml'> " + "<head>" + "<meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>" + "<title>Untitled Document</title>" + "</head>" + "<body>" + "<table width='450' border='1' cellspacing='0' cellpadding='3'>" + " <tr>" + " <td width='140' style='font-weight:bold;'>REFERENCE #: </td>" + " <td><span style='font-weight:bold;'>" + lastId.ToString() + "</span></td></tr></table>" + " <p style='font-weight:bold; padding-top:10px;'>CUSTOMER INFORMATION</p>" + " <table width='450' border='1' cellspacing='0' cellpadding='3'>" + " <tr>" + " <td width='140' style='font-weight:bold;'>Name1: </td>" + " <td><span>" + TextBox1.Text + "</span></td></tr>" + " <tr>" + " <td style='font-weight:bold;'>Name2: </td>" + " <td><span>" + TextBox2.Text + "</span></td></tr>" + " <tr>" + " <td style='font-weight:bold;'>Email: </td>" + " <td><span>" + TextBox4.Text + "</span></td></tr>" + " <tr>" + " <td style='font-weight:bold;'>" + Phone Number: " + "</td>" + " <td><span>" + TextBox5.Text + "</span></td> </tr>" + " <tr>" + " <td style='font-weight:bold;'>Company: </td>" + "<td><span> " + TextBox6.Text + " </span></td></tr>" + "<tr>" + "<td style='font-weight:bold;'>Country:</td>" + "<td><span>" + DropDownList1.SelectedItem.Text + "</span></td></tr>" + "</body>" + "</html>";This is the code i used to generate the HTML email. I get tags in the email. Not always but sometimes and not all the errors are same. Eeach time I get a tag at different place and sometimes i don't.
anantDD2007
Member
122 Points
21 Posts
Re: Problem with HTML tags
Dec 27, 2012 07:25 PM|LINK
Hi,
I think this is because your mail is getting treated as plain text. This is the issues with some mail servers.
I assume that you are using MailMessage class to send the emails.
Try setting the IsBodyHtml property of MailMessage object to TRUE. This will make the mail server process your mail body as an HTML.
Please mark this as answer if helps solving the issue.
Thanks,
Anant
praveen13788
Member
8 Points
43 Posts
Re: Problem with HTML tags
Dec 27, 2012 07:28 PM|LINK
objMail.BodyFormat = MailFormat.Html;
I have given this one already ....
bbcompent1
All-Star
32994 Points
8509 Posts
Moderator
Re: Problem with HTML tags
Dec 27, 2012 09:14 PM|LINK
Sometimes however the client may not be capable of displaying formatted HTML which renders as plain text. Check one of the client programs that is doing this to see if emails received are converted to plain text.