{"id":4463,"date":"2014-08-16T12:40:12","date_gmt":"2014-08-16T10:40:12","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=4463"},"modified":"2014-08-16T12:40:12","modified_gmt":"2014-08-16T10:40:12","slug":"eml-is-now-of-byte-type-cannot-implicitly-convert-type-byte-to-string","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/eml-is-now-of-byte-type-cannot-implicitly-convert-type-byte-to-string","title":{"rendered":"Eml is now of byte[] type (Cannot implicitly convert type &#8216;byte[]&#8217; to &#8216;string&#8217;)"},"content":{"rendered":"<p>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&#8217;s public interface. <\/p>\n<p>In most cases changes required will be very minor. Most common are data type changes from <em>string<\/em> to <em>byte[]<\/em> or <em>var<\/em> keyword.<\/p>\n<p>Below you can find a most common change guidance:<\/p>\n<h3>Downloading an email<\/h3>\n<p>change:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nstring eml = client.GetMessageByUID(uid);\r\nIMail email = new MailBuilder().CreateFromEml(eml);\r\n<\/pre>\n<p>to:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nbyte&#x5B;] eml = client.GetMessageByUID(uid);\r\nIMail email = new MailBuilder().CreateFromEml(eml);\r\n<\/pre>\n<h3>Saving an email to a file<\/h3>\n<p>change:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nstring eml = client.GetMessageByUID(uid);\r\nFile.WriteAllText(fileName, eml, Encoding.GetEncoding(1252));\r\n<\/pre>\n<p>to:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nbyte&#x5B;] eml = client.GetMessageByUID(uid);\r\nFile.WriteAllBytes(fileName, eml);\r\n<\/pre>\n<h3>Reading an email from a file<\/h3>\n<p>change:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nstring eml = File.ReadAllText(fileName, Encoding.GetEncoding(1252));\r\nIMail email = new MailBuilder().CreateFromEml(eml);\r\n<\/pre>\n<p>to:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nbyte&#x5B;] eml = File.ReadAllBytes(fileName);\r\nIMail email = new MailBuilder().CreateFromEml(eml);\r\n<\/pre>\n<h3>Uploading an email read from a file<\/h3>\n<p>change:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nstring eml = File.ReadAllText(fileName, Encoding.GetEncoding(1252));\r\nclient.UploadMessage(&quot;Inbox&quot;, eml);\r\n<\/pre>\n<p>to:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nbyte&#x5B;] eml = File.ReadAllBytes(fileName);\r\nclient.UploadMessage(&quot;Inbox&quot;, eml);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s public interface. In most cases changes required will be very minor. Most common are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1],"tags":[],"class_list":["post-4463","post","type-post","status-publish","format-standard","hentry","category-mail-dll","category-news"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4463"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=4463"}],"version-history":[{"count":11,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4463\/revisions"}],"predecessor-version":[{"id":4786,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4463\/revisions\/4786"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=4463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=4463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=4463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}