We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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.


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());


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