MailMessageLoadMessage Method (Byte)
Loads the message from a byte array.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public bool LoadMessage(
	byte[] rawData


Type: SystemByte
The byte array containing the MIME source of the message.

Return Value

Type: Boolean
true if the message was successfully loaded; otherwise, false.
MailBeeInvalidArgumentExceptionrawData is a null reference (Nothing in Visual Basic).
MailBeeDataParsingExceptionOutlook .MSG file is being loaded instead of MIME (.EML) and ThrowExceptions is true.

The MIME source of the message is the contents of .EML file (which you can import with LoadMessage(String) method).

To get an existing message as a byte array, use GetMessageRawData method.

Note Note
This method can change the contents of the source byte array. This may only occur in extremely rare case when line endings in there are single CR characters rather than CRLF pairs (correct endings) or single LF characters (incorrect but widely used). In this case, MailBee normalizes the data by replacing single CRs with LFs (not changing the length of the array). If for some reason you want to preserve the source data intact, make a copy of the source array before passing it to this method. To avoid unnecessary memory consumption, you can first check if the message data indeed contains CR line endings, and make a copy of the data only in this rare case.
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(String) method to load a message from a file.
// 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();
See Also