Convert Email Files between MSG, EML and MHT in C# and VB.NET

The GemBox.Email library supports reading and writing email messages of the following file formats:

  • MSG (Outlook Item)
  • EML (Electronic Mail Format)
  • MHT or MHTML (MIME HTML)

You can load an email file from one format and save it as another format, thus achieving a straightforward conversion of emails from your C# and VB.NET code.

Both the loaded input file and saved output file can be obtained as physical files (when providing a file's path) or as in-memory files (when providing a file's stream).

The following example demonstrates how to convert an email by reading an input file, representing it with a MailMessage object, and saving it to the output file of the desired format.

Screenshot of converted email files
Converting email formats in C# and VB.NET
Upload your file (Drag file here)
using GemBox.Email;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        // Convert email from one format into another.
        MailMessage message = MailMessage.Load("%InputFileName%");
        message.Save("Convert.%OutputFileType%");
    }
}
Imports GemBox.Email

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        ' Convert email from one format into another.
        Dim message As MailMessage = MailMessage.Load("%InputFileName%")
        message.Save("Convert.%OutputFileType%")
    End Sub
End Module

Check next example or download examples from GitHub.