{"id":2629,"date":"2012-04-12T11:23:07","date_gmt":"2012-04-12T09:23:07","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=2629"},"modified":"2012-05-15T16:03:53","modified_gmt":"2012-05-15T14:03:53","slug":"create-html-from-plain-text-email","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/create-html-from-plain-text-email","title":{"rendered":"Create HTML from plain text email"},"content":{"rendered":"<p>Mail.dll MIME and <a href=\"\/mail\">email component<\/a> may be used to retrieve plain-text body or HTML body from an email message.<\/p>\n<p>If a message contains HTML, no conversion is necessary. You just need to use <em>HTML <\/em>property of <em>IMail <\/em>interface.<\/p>\n<p>If however an email does not contain HTML and only plain-text content is available, many times plain-text needs be converted to HTML.<\/p>\n<p>You can use <strong>GetBodyAsHtml<\/strong> method that<strong> always returns body in HTML format<\/strong> (it uses <em>IMail.HTML<\/em> property or creates valid HTML from <em>IMail.Text<\/em>).<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nIMail email = ...\r\n\r\nstring html = email.GetBodyAsHtml();\r\nConsole.WriteLine(html);\r\n\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nDim email As IMail = ...\r\n\r\nDim html As String = email.GetBodyAsHtml()\r\nConsole.WriteLine(html)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[15,33,72,57],"class_list":["post-2629","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-c","tag-email-component","tag-html","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/2629"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=2629"}],"version-history":[{"count":3,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/2629\/revisions"}],"predecessor-version":[{"id":2847,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/2629\/revisions\/2847"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=2629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=2629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=2629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}