MIME | Blog | Limilabs https://www.limilabs.com/blog Sat, 16 Aug 2014 10:09:57 +0000 en-US hourly 1 https://wordpress.org/?v=6.3.4 Convert Outlook .msg file to MIME format in .NET https://www.limilabs.com/blog/convert-outlook-msg-file-to-mime-format-in-net https://www.limilabs.com/blog/convert-outlook-msg-file-to-mime-format-in-net#comments Mon, 14 Oct 2013 18:59:13 +0000 http://www.limilabs.com/blog/?p=4371 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 […]

The post Convert Outlook .msg file to MIME format in .NET first appeared on Blog | Limilabs.

]]>
Files containing the .msg file extension are most commonly created by or saved from within one of the Microsoft Outlook email applications.

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

The post Convert Outlook .msg file to MIME format in .NET first appeared on Blog | Limilabs.

]]>
https://www.limilabs.com/blog/convert-outlook-msg-file-to-mime-format-in-net/feed 2
Reading Outlook .msg file format in .NET https://www.limilabs.com/blog/reading-outlook-msg-file-format-net Mon, 14 Oct 2013 18:44:18 +0000 http://www.limilabs.com/blog/?p=4370 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 […]

The post Reading Outlook .msg file format in .NET first appeared on Blog | Limilabs.

]]>
Files containing the .msg file extension are most commonly created by or saved from within one of the Microsoft Outlook email applications.

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 read .msg files, 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 access its most common properties, such as subject, sender and attachments.

// C#

using (MsgConverter converter = new MsgConverter(@"c:\outlook1.msg"))
{
    if (converter.Type == MsgType.Note)
    {
        IMail email = converter.CreateMessage();

        Console.WriteLine("Subject: {0}", email.Subject);
        Console.WriteLine("Sender name: {0}", email.Sender.Name);
        Console.WriteLine("Sender address: {0}", email.Sender.Address);

        Console.WriteLine("Attachments: {0}", email.Attachments.Count);
        foreach (MimeData attachment in email.Attachments)
        {
            attachment.Save(@"c:\" + attachment.SafeFileName);
        }
    }
}
' VB.NET

Using converter As New MsgConverter("c:\outlook1.msg")
    If converter.Type = MsgType.Note Then
        Dim email As IMail = converter.CreateMessage()

        Console.WriteLine("Subject: {0}", email.Subject)
        Console.WriteLine("Sender name: {0}", email.Sender.Name)
        Console.WriteLine("Sender address: {0}", email.Sender.Address)
        
        Console.WriteLine("Attachments: {0}", email.Attachments.Count)
        For Each attachment As MimeData In email.Attachments
            attachment.Save("c:\" + attachment.SafeFileName)
        Next

    End If
End Using

You can read more on how to access To, Cc, Bcc fields.

The post Reading Outlook .msg file format in .NET first appeared on Blog | Limilabs.

]]>