In this simple tutorial, we will learn how to convert EML to MSG using C# along with detailed steps to set up the environment. In order to convert EML to MSG C# based API can be used and you can use this example in any of the commonly available operating systems like Windows, macOS, or Linux.
Steps to Convert EML to MSG using C#
- Install Aspose.Email library from NuGet package manager tool in Visual Studio
- Import the Aspose.Email namespace in your project
- Set the EmlLoadOptions for loading EML file
- Initialize the MailMessage class object to load the source EML file
- Convert the EML to MSG file using Save method
By using the above steps in C# EML to MSG conversion application is developed. The process is initiated by loading the source EML file from the disk using the MailMessage class object. Then the loaded EML file is saved as MSG file on the disk using either of SaveOptions.DefaultMsg and SaveOptions.DefaultMsgUnicode enumerators in the Save method.
Code to Convert EML to MSG in C#
The above example in C# convert EML to MSG file on the disk with the help of simple API calls and well defined steps. You can set different EmlLoadOptions including PreserveTnefAttachments and PreserveEmbeddedMessageFormat before loading the EML file. You can also use the above example to load the EML file using the default options by using default constructor of EmlLoadOptions class.
To convert EML to MSG C# based API is explored in this article. If you are looking for how to convert EML to PDF in C#, refer to the article on How to Convert Outlook Email to PDF using C#.