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 regular string
string mime = email.RenderEml();
// 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 regular string
Dim mime As String = email.RenderEml()
' Save message to file using MIME message format
email.Save("c:\mime.eml")
End If
End Using