This C# example demonstrates how to load an email object from a byte array:
private void LoadEmailFromByteArray()
{
// First, load an email from a file into a byte array.
// (This example really begins after we have the exact bytes
// from the file in a byte array.)
byte[] emailBytes = System.IO.File.ReadAllBytes("email.eml");
// There are two approaches.
// (1) Convert the byte array to a string and then call
// Chilkat.Email.SetFromMimeText to load it into an email object.
// However, if an 8bit encoding is used, you'll need to know
// the character encoding in order to convert the bytes to
// a string. This is the reason for 7bit (quoted-printable) encodings
// in MIME -- so you don't have to deal with this mess.
// If the content-type of each part within the MIME is quoted-printable
// or base64, you can assume us-ascii.
//
// (2) A second approach is to use Chilkat.Mime to load the byte array
// into a Chilkat.Mime object and then convert that to a Chilkat.Email
// object. The Chilkat.Mime object provides a LoadMimeBytes method intended
// to handle binary MIME and MIME with 8bit content-types.
//
// Approach #1: Convert to a string and load into a Chilkat.Email object:
string mimeStr = System.Text.Encoding.ASCII.GetString(emailBytes);
Chilkat.Email email = new Chilkat.Email();
email.SetFromMimeText(mimeStr);
// Approach #2: Load bytes into Chilkat.Mime, then convert to Chilkat.Email:
Chilkat.Mime mime = new Chilkat.Mime();
// The following two methods return true/false success statuses, and they really should be checked...
mime.UnlockComponent("Anything for 30-day trial");
mime.LoadMimeBinary(emailBytes);
email.SetFromMimeObject(mime);
}