{"id":4864,"date":"2015-01-02T09:06:13","date_gmt":"2015-01-02T07:06:13","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=4864"},"modified":"2015-01-02T10:57:50","modified_gmt":"2015-01-02T08:57:50","slug":"joining-message-partial-emails","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/joining-message-partial-emails","title":{"rendered":"Joining message\/partial emails"},"content":{"rendered":"<p>With Mail.dll you can join a message split across multiple message\/partial emails.<\/p>\n<p>&#8220;Message\/partial&#8221; emails allow large objects to be delivered as several mail messages and automatically joined by the receiving client. This mechanism can be used when intermediate transport agents, such as SMTP servers, are limiting the size of individual mails that can be sent. Content-Type &#8220;message\/partial&#8221; indicates that the body contains a fragment of a larger email.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nIMail part1 = ...\r\nIMail part2 = ...\r\n\r\nPartialMailJoiner joiner = new PartialMailJoiner();\r\njoiner.Add(part1);\r\njoiner.Add(part2);\r\n\r\nIMail email = joiner.Join();\r\nvar attachments = email.Attachments;\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nDim part1 As IMail = &quot;...&quot;\r\nDim part2 As IMail = &quot;...&quot;\r\n\r\nDim joiner As New PartialMailJoiner()\r\njoiner.Add(part1)\r\njoiner.Add(part2)\r\n\r\nDim email As IMail = joiner.Join()\r\nDim attachments = email.Attachments\r\n<\/pre>\n<p><em>PartialMailJoiner.Add<\/em> method checks if all parts of message\/partial email are present and you can use <em>PartialMailJoiner.Join<\/em> method:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nIMail part1 = ...\r\nIMail part2 = ...\r\n\r\nList&lt;IMail&gt; parts = new List&lt;IMail&gt;{part1, part2};\r\n\r\nPartialMailJoiner joiner = new PartialMailJoiner();\r\n\r\nforeach (IMail part in parts)\r\n{\r\n    if (part.IsPartial)\r\n    {\r\n        bool allPartsPresent = joiner.Add(part);\r\n\r\n        if (allPartsPresent)\r\n        {\r\n            IMail email = joiner.Join();\r\n            var attachments = email.Attachments;\r\n        }\r\n    }\r\n}\r\n\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nDim part1 As IMail = ...\r\nDim part2 As IMail = ...\r\n\r\nDim parts As New List(Of IMail)() From { _\r\n\tpart1, _\r\n\tpart2 _\r\n}\r\n\r\nDim joiner As New PartialMailJoiner()\r\n\r\nFor Each part As IMail In parts\r\n    If part.IsPartial Then\r\n        Dim allPartsPresent As Boolean = joiner.Add(part)\r\n\r\n\tIf allPartsPresent Then\r\n            Dim email As IMail = joiner.Join()\r\n\t    Dim attachments = email.Attachments\r\n        End If\r\n    End If\r\nNext\r\n<\/pre>\n<p>Joining fragmented message is a bit tricky. Messages filtered using Content-Type&#8217;s id property and then sorted by Content-Type&#8217;s number property. Note that part numbering begins with 1, not 0.<\/p>\n<p>The headers of the encapsulated message must be merged with the headers of the enclosing entities.  Following rules must be used:<\/p>\n<ul>\n<li>All of the header fields from the initial enclosing message, except those that start with &#8220;Content-&#8221; and the specific header fields&#8221; &#8220;Subject&#8221;, &#8220;Message-ID&#8221;, &#8220;Encrypted&#8221;, and &#8220;MIME-Version&#8221;, must be copied, in order, to the new message.<\/li>\n<li>The header fields in the enclosed message which start with &#8220;Content-&#8220;, plus the &#8220;Subject&#8221;, &#8220;Message-ID&#8221;, &#8220;Encrypted&#8221;, and &#8220;MIME-Version&#8221; fields, must be appended, in order, to the header fields of the new message. all others will be ignored and dropped.<\/li>\n<li>All of the header fields from the second and any subsequent enclosing messages are ignored.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>With Mail.dll you can join a message split across multiple message\/partial emails. &#8220;Message\/partial&#8221; emails allow large objects to be delivered as several mail messages and automatically joined by the receiving client. This mechanism can be used when intermediate transport agents, such as SMTP servers, are limiting the size of individual mails that can be sent. [&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":[33,110],"class_list":["post-4864","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-email-component","tag-partial"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4864"}],"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=4864"}],"version-history":[{"count":13,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4864\/revisions"}],"predecessor-version":[{"id":4883,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4864\/revisions\/4883"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=4864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=4864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=4864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}