{"id":4804,"date":"2014-10-01T17:08:18","date_gmt":"2014-10-01T15:08:18","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=4804"},"modified":"2014-09-09T17:55:49","modified_gmt":"2014-09-09T15:55:49","slug":"applesingle-appledouble-email-attachments","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/applesingle-appledouble-email-attachments","title":{"rendered":"Processing applesingle and appledouble email attachments"},"content":{"rendered":"<p>Mail.dll now supports applesingle and appledouble email attachments. <\/p>\n<p>AppleSingle and AppleDouble are file formats developed to store Mac OS &#8220;dual-forked&#8221; files (data fork and resource fork)<\/p>\n<p>AppleSingle combines both file forks and the related Finder meta-file information into a single file MIME entity, usually with application\/applesingle content-type email header. Applesingle files are parsed by Mail.dll and data fork is extracted as a standard email attachment available through <em>IMail.Attachments <\/em>collection.<\/p>\n<p>AppleDouble stores both forks as two separate files. Thus it uses multipart mime type &#8211; inside two MIME entities are stored: application\/applefile, which contains resource fork only, and regular MIME attachment e.g. application\/octet-stream content-type.<\/p>\n<p>In both cases you simply use <em>IMail.Attachments<\/em> collection to access attachments.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nbyte&#x5B;] eml = ...;\r\n\r\nIMail mail = new MailBuilder().CreateFromEml(eml);\r\nAssert.AreEqual(1, mail.Attachments.Count);\r\nMimeData att = (MimeData) mail.Attachments&#x5B;0];\r\n\r\nbyte&#x5B;] data = att.Data; \/\/ data fork\r\n<\/pre>\n<p>You can control, if apple attachments should be processed using <em>MailBuilder.ProcessAppleAutomatically<\/em> property. When it is set to false applesingle files are not parsed and data fork is not extracted.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nbyte&#x5B;] eml = ...;\r\n\r\nMailBuilder builder = new MailBuilder();\r\nbuilder.ProcessBinHexAutomatically = false;\r\nIMail mail = builder.CreateFromEml(eml);\r\n\r\nMimeAppleSingle appleSingle = (MimeAppleSingle) mail.Attachments&#x5B;0];\r\n\r\nAssert.AreEqual(ContentType.ApplicationAppleSingle, appleSingle.ContentType);\r\n\r\nbyte&#x5B;] resource = appleSingle.AppleSingle.Resources;\r\nstring name = appleSingle.AppleSingle.RealName;\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Mail.dll now supports applesingle and appledouble email attachments. AppleSingle and AppleDouble are file formats developed to store Mac OS &#8220;dual-forked&#8221; files (data fork and resource fork) AppleSingle combines both file forks and the related Finder meta-file information into a single file MIME entity, usually with application\/applesingle content-type email header. Applesingle files are parsed by Mail.dll [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[108,107,74,33],"class_list":["post-4804","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-appledouble","tag-applesingle","tag-attachments","tag-email-component"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4804"}],"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=4804"}],"version-history":[{"count":4,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4804\/revisions"}],"predecessor-version":[{"id":4808,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4804\/revisions\/4808"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=4804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=4804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=4804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}