Convert Outlook .msg file to MIME format in .NET
Files containing the .msg file extension are most commonly created by or saved from within one of the Microsoft Outlook email applications.
- Reading Outlook .msg file format in .NET
- Convert Outlook .msg file to MIME format in .NET
The MSG file contains information about a saved email file including the date of the message, the subject, who sent it, who received it and the contents of the email associated with the file. If attachments ares included with an email, that information will also be saved within the associated MSG file.
MsgConverter , than can be used to convert .msg files to MIME, is written in pure .NET, it does not require registration or any other components or libraries (including Outlook).
The following code snippet reads .msg file in .NET and saves it using MIME format to disk. MIME is shorthand for Multipurpose Internet Mail Extensions and is an Internet standard used to store and transport email messages.
// C# using (MsgConverter converter = new MsgConverter(@"c:\outlook1.msg")) { if (converter.Type == MsgType.Note) { IMail email = converter.CreateMessage(); // Render message using MIME format to byte array byte[] mime = email.Render(); // Save message to file using MIME message format email.Save(@"c:\mime.eml"); } }
' VB.NET Using converter As New MsgConverter("c:\outlook1.msg") If converter.Type = MsgType.Note Then Dim email As IMail = converter.CreateMessage() ' Render message using MIME format to byte array Dim mime As Byte() = email.Render() ' Save message to file using MIME message format email.Save("c:\mime.eml") End If End Using
December 5th, 2017 at 08:35
Is this the same process for convert .eml and .msg files into pdf files?
December 5th, 2017 at 13:02
@Andriy,
Mail.dll provides easy access to MIME email messages and a way for converting Outlook’s msg format to MIME message.
When you have IMail object instance, you can easy access all email properties (such as Subject, Text, Attachments,…) and use external tool (such as PDFsharp) to a create pdf file.