Email to Html Conversion

Hi ,


I have need proper code to convert email body to html file. I have also look some old post for refer but in that post convert from file have extension “.eml” but before that their is no information.

So, please help me out their and provide proper code for conversion.


Thanks,

Rakesh Kumar



Hi Rakesh,


Thank you for posting your inquiry.

You can use the following sample code to convert a message to HTML. Please try it at your end and let us know if you need any further assistance in this regard.

Sample Code:

MailMessage msg = MailMessage.load(dataDir + “Message.msg”);
msg.save(dataDir + “SavingMessageAsHTML_out1.html”, SaveOptions.getDefaultHtml());

//or

MailMessage eml = MailMessage.load(dataDir + “test.eml”);
HtmlSaveOptions options = SaveOptions.getDefaultHtml();
options.setEmbedResources(false);
options.setHtmlFormatOptions(HtmlFormatOptions.WriteHeader | HtmlFormatOptions.WriteCompleteEmailAddress);
eml.save(dataDir + “SavingMessageAsHTML_out2.html”, options);