MailBee.NET Objects 6.0

MsgConvert Class

Provides methods for parsing and converting Outlook .MSG files/streams (in OLE2 format) into MailMessage objects and files/streams in .EML format (RFC822 MIME), and for building .MSG files/streams from MailMessage objects and .EML files/streams.

For a list of all members of this type, see MsgConvert Members.

System.Object
   MailBee.Outlook.MsgConvert

public class MsgConvert

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

You can perform the following operations using this class:

Prior to creating instances of this class, the correct license key must be set. See LicenseKey property for details.

Note   This class can only deal with OLE2 .MSG files. XML mail messages (can be created by Outlook 2007 and above) are not supported.

Example

This sample converts .MSG file into MailMessage object and then saves the resulting converted message to .EML file. It's assumed LicenseKey is already assigned (for instance, in app.config or web.config file).

Note   This sample shows how to use streams and MailMessage objects within the conversion (this also allows you to modify the resulting mail message prior to saving it into a file. If you only need to convert .MSG file into .EML (or vice versa), you can simply use MsgToEml or EmlToMsg methods.
[C#]
// To use the code below, import these namespaces at the top of your code.
using System.IO;
using MailBee.Outlook;
using MailBee.Mime;

// The actual code (put it into a method of your class).
FileStream fs = new FileStream(@"C:\Mail\test.msg", FileMode.Open);
MsgConvert conv = new MsgConvert();
MailMessage msg = conv.MsgToMailMessage(fs);
fs.Close();
msg.SaveMessage(@"C:\Mail\test.eml");
[Visual Basic]
' To use the code below, import these namespaces at the top of your code.
Imports System.IO
Imports MailBee.Outlook
Imports MailBee.Mime

' The actual code (put it into a method of your class).
Dim fs As FileStream = New FileStream("C:\Mail\test.msg", FileMode.Open)
Dim conv As MsgConvert = New MsgConvert
Dim msg As MailMessage = conv.MsgToMailMessage(fs)
fs.Close()
msg.SaveMessage("C:\Mail\test.eml")

Requirements

Namespace: MailBee.Outlook

Assembly: MailBee.NET (in MailBee.NET.dll)

See Also

MsgConvert Members | MailBee.Outlook Namespace