Apache POI

MSGReader

 
 

.NET Library for Outlook MSG Files Processing

Open Source C# .NET API to Read, Write and Convert MS Outlook MSG and EML files.

 

MSGReader is Open Source C# .NET library for reading Outlook MSG and EML files. It enables developers to read outlook MSG and EML files without using Microsoft Outlook. The most common outlook objects such as E-mail, Appointment, Task, Contact card & Sticky note are fully supported. All body types in MSG files, such as Text, HTML, HTML embedded into RTF and RTF are also supported.

There are a few options available for manipulation of MSG files in MSGReader.  It allows developers to remove attachments from email message; they can also save the file to a new one. 

Getting Started with MSGReader

The easiest way to install MSGReader is via NuGet. To use it from Visual Studio’s Package Manager Console, please enter the following command.

Here is the command

 Install-Package MSGReader 

Using MSGReader from a COM based language like VB script or VB6.

First you need to download the latest version and then open the MSGReader project, set Platform target to X86 & then build the code in release mode, Get "MsgReader.dll" file from BuildOutput folder & Copy the file to the desired location. After that Register the file for COM interop using the following command.

Here is the command

 Regasm.exe /codebase MsgReader.dll 

That’s it, now you can call it from VBA, VB6 and any other COM compatible language.

Here is the code

 dim msgreader
set msgreader = createobject("MsgReader.Reader")

msgreader.ExtractToFolderFromCom "the msg file to read", "the folder where to place the extracted files"

Read & Save Outlook MSG Message Attachment using .NET

MSGReader enables C# developers to access email message & its attachment of an Outlook MSG and EML file. It provides support for reading an Outlook MSG file and save the message body and all its attachments to an output folder

Read MSG data - C#

// Read a email .msg file
Message message = new MsgReader.Outlook.Storage.Message("fileformat.msg");
// Read sender
Console.WriteLine("Sender:" + message.Sender);
// Read sent on
Console.WriteLine("SentOn:" + message.SentOn);
// Read recipient to
Console.WriteLine("recipientsTo:" + message.GetEmailRecipients(MsgReader.Outlook.RecipientType.To, false, false));
// Read recipient cc
Console.WriteLine("recipientsCc:" + message.GetEmailRecipients(MsgReader.Outlook.RecipientType.Cc, false, false));
// Read subject
Console.WriteLine("subject:" + message.Subject);
// Read body html
Console.WriteLine("htmlBody:" + message.BodyHtml);

Convert Outlook MSG as Text File using .NET API

MSGReader API provides the features for saving outlook MSG as text file using .NET API. Developers can easily access the MSG file contents. Create an instance of the save file dialog box and save the message as TXT file format.