Loads the message from a byte array.
true if the message was successfully loaded; otherwise, false.
The MIME source of the message is the contents of .EML file (which you can import with LoadMessage method).
To get an existing message as a byte array, use GetMessageRawData method.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | rawData is a null reference (Nothing in Visual Basic). |
This sample loads the message from a byte array and displays the subject of the message. Reading from a stream is used for demonstration purposes only. In real-world apps, it's easier to use LoadMessage method to load a message from a file.
[C#] // To use the code below, import these namespaces at the top of your code. using System.IO; using MailBee; using MailBee.Mime; // The actual code (put it into a method of your class). byte[] msgBytes = null; using (BinaryReader br = new BinaryReader(File.OpenRead(@"C:\Docs\TestMail.eml"))) { FileInfo fi = new FileInfo(@"C:\Docs\TestMail.eml"); msgBytes = br.ReadBytes((int)fi.Length); } MailMessage msg = new MailMessage(); msg.LoadMessage(msgBytes); Console.WriteLine(msg.Subject);
[Visual Basic] ' To use the code below, import these namespaces at the top of your code. Imports System.IO Imports MailBee Imports MailBee.Mime ' The actual code (put it into a method of your class). Dim msgBytes As Byte() = Nothing Dim br As BinaryReader Try br = New BinaryReader(File.OpenRead("C:\Docs\TestMail.eml")) Dim fi As New FileInfo("C:\Docs\TestMail.eml") msgBytes = br.ReadBytes(fi.Length) Finally If Not br Is Nothing Then br.Close() End If End Try Dim msg As New MailMessage msg.LoadMessage(msgBytes) Console.WriteLine(msg.Subject)
MailMessage Class | MailBee.Mime Namespace | MailMessage.LoadMessage Overload List | GetMessageRawData