+1 vote

I have the text message with lots of \n\r now I want to convert it in HTML, Is there any way to do it?

by (1.6k points)
As I want to use html template in reply, and if I pass body in text and use HTML template it won't work.

1 Answer

0 votes

Have you tried using IMail.GetBodyAsHtml() ?
It converts pain text emails to basic HTML.

by (279k points)
I have the saprate text from the object(Imail),and that text I want to convert to html text.
 ReplyBuilder replyBuilder = original.Reply();
 replyBuilder.HtmlReplyTemplate =Settings.AppSettings.Email.HtmlReplyTemplate;
 replyBuilder.SubjectReplyTemplate = "Re: [Original.Subject]";
 replyBuilder.Html = Body;

In body i have lot's of text with entity names. I want to convert body to html and assign it to
It is also not working when i am assing replybuilder.htmlreplytemplate with replybuilder.text it takes only replybuilder.html
Any reply on this?
To clarify this issue, when calling GetBodyAsHtml(), special characters are escaped (i.e. ' becomes '). When adding this to an email and then sending it using SmtpClient.SendMessage, the & of &apos gets escaped resulting in &pos;

How do we prevent the double escaping?
We can use System.Net.WebUtility.HtmlDecode to convert entity like ' to '