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

GemBox.Email library supports loading and saving email messages from / to the following file formats:

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

The following example demonstrates how to load an email message from one file format and save it to another file format.

Screenshot

Convert Screenshot

See the full code below, use RUN EXAMPLE to execute.

Upload your file (Drag files here)

1using GemBox.Email;
2using GemBox.Email.Imap;
3using GemBox.Email.Mime;
4using GemBox.Email.Pop;
5using GemBox.Email.Smtp;
6using System;
7using System.Collections.Generic;
8using System.Globalization;
9using System.Text;
10
11class Sample
12{
13    [STAThread]
14    static void Main(string[] args)
15    {
16        // If using Professional version, put your serial key below.
17        ComponentInfo.SetLicense("FREE-LIMITED-KEY");
18
19        // Load message
20        MailMessage message = MailMessage.Load("Attachment.eml");
21
22        // In order to achieve the conversion of a loaded email message 
23        // to some other file format, we just need to 
24        // save a MailMessage object to desired output file format.
25        message.Save("Convert.msg");
26    }
27}
1Imports System.Globalization
2Imports System.Text
3Imports GemBox.Email
4Imports GemBox.Email.Imap
5Imports GemBox.Email.Mime
6Imports GemBox.Email.Pop
7Imports GemBox.Email.Smtp
8
9Module Samples
10
11    Sub Main()
12
13        ' If using Professional version, put your serial key below.
14        ComponentInfo.SetLicense("FREE-LIMITED-KEY")
15
16        ' Load message
17        Dim message as MailMessage = MailMessage.Load("Attachment.eml")
18
19        ' In order to achieve the conversion of a loaded email message
20        ' to some other file format, we just need to 
21        ' save a MailMessage object to desired output file format.
22        message.Save("Convert.msg")
23
24    End Sub
25
26End Module

Check next sample or find out more about GemBox.Email and GemBox Software.