HTML JPG EMAIL XML EML
  Product Family
PDF

Convert EML to PDF via C#

Convert EML to PDF without needing Microsoft® Outlook® or Thunderbird® installed.

In order to convert EML to PDF, we’ll use Aspose.Email for .NET API which is a feature-rich, powerful and easy to use document manipulation and conversion API for C# platform. Open NuGet package manager, search for Aspose.Email and install. You may also use the following command from the Package Manager Console.

Package Manager Console Command


PM> Install-Package Aspose.EMAIL

Steps to Convert EML to PDF via C#

.NET programmers can easily load & convert EML files to PDF in just a few lines of code.

  1. Load source EML file using MailMessage.Load
  2. Save EML as MHTML in MemoryStream using MailMessage.Save method
  3. Load MHTML from MemoryStream with Aspose.Words.Document constructor
  4. Call Document.Save method while specifying PdfSaveOptions

System Requirements

Before running the .NET conversion source code, make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with .NET Framework, .NET Core, and PHP, VBScript, Delphi, C++ via COM Interop.
  • Development environment like Microsoft Visual Studio.
  • Aspose.EMAIL for .NET DLL referenced in your project.
 

This sample code shows EML to PDF C# Conversion

string dataDir = RunExamples.GetDataDir_KnowledgeBase();
MailMessage mailMsg = MailMessage.Load(dataDir + "message3.eml");
MemoryStream ms = new MemoryStream();
mailMsg.Save(ms, Aspose.Email.SaveOptions.DefaultMhtml);

// create an instance of LoadOptions and set the LoadFormat to Mhtml
var loadOptions = new Aspose.Words.Loading.LoadOptions();
loadOptions.LoadFormat = LoadFormat.Mhtml;

// create an instance of Document and load the MTHML from MemoryStream
var document = new Aspose.Words.Document(ms, loadOptions);

// create an instance of HtmlSaveOptions and set the SaveFormat to Html
var saveOptions = new Aspose.Words.Saving.PdfSaveOptions();
document.Save(dataDir + "SaveEmailAsPDF_out.pdf", saveOptions);
 
  • Free App to Convert EML to PDF

    Other Supported Conversions

    You can also convert EML into many other file formats including few listed below.

    EML TO EMLX (Apple EMLX Format)
    EML TO HTML (Hyper Text Markup Language)
    EML TO ICS (iCalendar)
    EML TO MBOX (Electronic Mail Messages)
    EML TO MHTML (Web Page Archive Format)
    EML TO MSG (Outlook & Exchange Format)
    EML TO OFT (Outlook Email Templates)
    EML TO OST (Offline Storage Files)
    EML TO PST (Outlook Personal Storage Files)
    EML TO VCF (Virtual Card Format)