In order to embed the content of the emails into the web pages, you would need to convert them into HTML format. For such cases, this article covers how to automate an email to HTML conversion in .NET applications. Particularly, you will learn how to convert MSG and EML emails to HTML or MHTML format using C#.
- C# Email to HTML Converter API
- Convert MSG/EML to HTML using C#
- Convert MSG/EML to MHTML using C#
- Get a Free API License
C# Email to HTML Converter API
For email to HTML conversion, we’ll use Aspose.Email for .NET. The said API is designed to create, manipulate, convert, and send emails without installing MS Outlook or any other software. You can either download the API’s DLL or install it within your .NET application using NuGet.
PM> Install-Package Aspose.Email
Convert Emails to HTML in C#
The following sections demonstrate how to convert emails to HTML or MHTML formats.
Convert MSG or EML to HTML using C#
The following are the steps to convert an MSG or EML email file to HTML using Aspose.Email for .NET.
- Load the EML or MSG email file using MailMessage class.
- Convert email to HTML using MailMessage.Save(String, SaveOptions.DefaultHtml) method.
The following code sample shows how to convert an MSG/EML email to HTML using C#.
Convert MSG or EML to MHTML using C#
MHTML is a web page archive format that is used to encapsulate the HTML content along with the external resources. In order to perform an email to MHTML conversion, you only need to provide SaveOptions.DefaultMhtml as a second parameter to MailMessage.Save() method. The following are the steps to perform this operation.
- Load the EML or MSG email file using MailMessage class.
- Convert email to MHTML using MailMessage.Save(String, SaveOptions.DefaultMhtml) method.
The following code sample shows how to convert an MSG or EML file to MHTML using C#.
Get a Free API License
You can try Aspose.Email for .NET without evaluation limitations for free. Get a free temporary license now.
Live Demo
Conclusion
In this article, you have learned how to convert emails to HTML or MHTML formats using C#. The steps along with API references and code samples have shown how to perform MSG/EML to HTML/MHTML conversion. You can explore more about the C# email API using documentation.