Eml is now of byte[] type (Cannot implicitly convert type ‘byte[]’ to ‘string’)

In most recent version of Mail.dll we decided to change how email data is internally stored. This improves both memory usage and raw, not encoded utf-8 data handling. As every major change this leads to a small breaking changes in Mail.dll’s public interface.

In most cases changes required will be very minor. Most common are data type changes from string to byte[] or var keyword.

Below you can find a most common change guidance:

Downloading an email

change:

string eml = client.GetMessageByUID(uid);
IMail email = new MailBuilder().CreateFromEml(eml);

to:

byte[] eml = client.GetMessageByUID(uid);
IMail email = new MailBuilder().CreateFromEml(eml);

Saving an email to a file

change:

string eml = client.GetMessageByUID(uid);
File.WriteAllText(fileName, eml, Encoding.GetEncoding(1252));

to:

byte[] eml = client.GetMessageByUID(uid);
File.WriteAllBytes(fileName, eml);

Reading an email from a file

change:

string eml = File.ReadAllText(fileName, Encoding.GetEncoding(1252));
IMail email = new MailBuilder().CreateFromEml(eml);

to:

byte[] eml = File.ReadAllBytes(fileName);
IMail email = new MailBuilder().CreateFromEml(eml);

Uploading an email read from a file

change:

string eml = File.ReadAllText(fileName, Encoding.GetEncoding(1252));
client.UploadMessage("Inbox", eml);

to:

byte[] eml = File.ReadAllBytes(fileName);
client.UploadMessage("Inbox", eml);

Questions?

Consider using our Q&A forum for asking questions.