Create HTML from plain text email

Mail.dll MIME and email component may be used to retrieve plain-text body or HTML body from an email message.

If a message contains HTML, no conversion is necessary. You just need to use HTML property of IMail interface.

If however an email does not contain HTML and only plain-text content is available, many times plain-text needs be converted to HTML.

You can use GetBodyAsHtml method that always returns body in HTML format (it uses IMail.HTML property or creates valid HTML from IMail.Text).

// C#

IMail email = ...

string html = email.GetBodyAsHtml();
Console.WriteLine(html);

' VB.NET

Dim email As IMail = ...

Dim html As String = email.GetBodyAsHtml()
Console.WriteLine(html)

Tags:    

Questions?

Consider using our Q&A forum for asking questions.