EML to Html file conversion

Hi,

How to convert EML, MSG and MHT files to html format using Aspose.Emails.dll in C# application.

Thanks,

Dhivya

Hi Dhivya.


Thank you for your inquiry.

Aspose.Email for .NET component can convert the email messages to MHTML format only. But with the collaboration of Aspose.Words for .NET component, you can convert MSG, EML and MHTML to HTML format. Please check the below source code for your reference,

C#

//load email message into an instance of MailMessage
var message = Aspose.Email.Mail.MailMessage.Load(“C:\temp\message.msg”);

//create an instance of MemoryStream to store the intermediate data (mhtml)
var stream = new System.IO.MemoryStream();

//convert the email message to MHTML and store in MemoryStream
message.Save(stream, MailMessageSaveType.MHtmlFromat);

//create an instance of LoadOptions and set the LoadFormat to Mhtml
var loadOptions = new Aspose.Words.LoadOptions();
loadOptions.LoadFormat = LoadFormat.Mhtml;

//create an instance of Document and load the MTHML from MemoryStream
var document = new Aspose.Words.Document(stream, loadOptions);

//create an instance of HtmlSaveOptions and set the SaveFormat to Html
var saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Html);

//save the document to Html file
document.Save(“C:\temp\output.html”, saveOptions);

Hi,

How to remove all the hyperlinks (ready only html file) while saving EML files to Html format.

Thanks,

Dhivya

Hi,

The HTML file generated from MHT file contains the "

Subject:
Attachments:ATT00001.vnd.ms-officetheme"

above the actual message. Please let me know the reason for this and also provide me the solution to avoid these extra line's.

Thanks,

Dhivya

Hi,


Please share you sample message file. Thanks

Hi,

Please find the attached sample test file with output HTML file.

Please let me know how to remove hyperlinks in the HTML file.

Thanks,

Dhivya

Hi Dhivya,


Thank you for providing the sample files.

Please note that Aspose.Email is an email manipulation component and it does not provide features like conversion to HTML. But as I have narrated earlier, you can achieve your goal by collaborating Aspose.Email with Aspose.Words component. Aspose.Email plays its part by converting any message type (MSG, EML) to MHTML, that is in turn fed to Aspose.Words for further processing.

I have requested you to provide us the sample message file, just to make sure that Aspose.Email is producing the correct MHTML file. By reviewing your sample, I have found that the MHTML is produced fine.

I suggest you to put your questions regarding the Hyperlinks or HTML formatting in Aspose.Words forum for further assistance. I am sure that the experts from Aspose.Words department will help you out very soon.

Thank you for understanding.