Skip to content
Search

Email:Eml2Msg

lastmod 2020-12-10created 2020-12-043 edits

A C# program that converts the eml format to the msg format using the Aspose library.

Setup project

Create the project with dotnet:

dotnet new console -lang C#

Add the Aspose.Email package via Nuget.

dotnet add package Aspose.Email --version 20.11.0

After writing the code, build the program.

dotnet build 

Run it.

dotnet run bin/Debug/netcoreapp3.1/tester.dll

Program.cs file

using Aspose.Email;
using System;

namespace tester
{
    class Program
    {
        static void Main(string[] args)
        {
            EmlLoadOptions lo = new EmlLoadOptions();
            lo.PreserveTnefAttachments = true;

            MailMessage message = MailMessage.Load("test.eml", lo);

            MsgSaveOptions so = new MsgSaveOptions(MailMessageSaveType.OutlookMessageFormatUnicode);
            message.Save("test2.msg", so);

            Console.WriteLine("Hello World!");
        }
    }
}

See also

author Zer0 sitemap