Provides static 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.OutlookMsg.MsgConvert
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
Prior to using this class, static LicenseKey property must be initialized.
Although this class has a constructor, you will not usually use it to create instances of this class because all the methods are static. The only need to create an instance is to access TrialDaysLeft property which you can use to learn how many days the component can still function in trial mode.
The component also extracts RTF (rich-text format) body from .MSG files. See RtfAsAttachment property for more information on how to extract the RTF body.
If the .MSG file provides HTML body, it will be extracted as well.
Note This class can only deal with OLE2 .MSG files. XML mail messages (can be created by Outlook 2007 and above) are not supported.
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; using MailBee.OutlookMsg; using MailBee.Mime; // The actual code (put it into a method of your class). FileStream fs = new FileStream(@"C:\Mail\test.msg", FileMode.Open); MailMessage msg = MsgConvert.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 Imports MailBee.OutlookMsg 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 msg As MailMessage = MsgConvert.MsgToMailMessage(fs) fs.Close() msg.SaveMessage("C:\Mail\test.eml")
Namespace: MailBee.OutlookMsg
Assembly: MailBee.NET (in MailBee.NET.dll)
MsgConvert Members | MailBee.OutlookMsg Namespace