From ca515fab8a7219b9e14663b7f59933f000bc805d Mon Sep 17 00:00:00 2001 From: Vlad Pitaru Date: Thu, 24 Apr 2014 17:03:02 +0300 Subject: [PATCH 1/2] Apple Mail sends attachments as inline are are marked as alternate views and the name of the attachment is lost. The behavious can be changed http://katiefloyd.me/blog/get-rid-of-inline-attachments-in-apple-mail otherwise an attachment will look like this: Content-Type: multipart/mixed; boundary=Apple-Mail-2--769176039 --Apple-Mail-2--769176039 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Hello --Apple-Mail-2--769176039 Content-Disposition: inline; filename=" xxx.pdf" Content-Type: application/pdf; name=" xxx.pdf" Content-Transfer-Encoding: base64 --- MessageBuilder.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MessageBuilder.cs b/MessageBuilder.cs index 31e367f..d50c5b6 100644 --- a/MessageBuilder.cs +++ b/MessageBuilder.cs @@ -370,8 +370,7 @@ internal static void AddBodypart(this MailMessage message, Bodypart part, string // Many attachments are missing the disposition-type. If it's not defined as alternative // and it has a name attribute, assume it is Attachment rather than an AlternateView. if (part.Disposition.Type == ContentDispositionType.Attachment || - (part.Disposition.Type == ContentDispositionType.Unknown && - preferAlternative == false && hasName)) + (preferAlternative == false && hasName)) message.Attachments.Add(CreateAttachment(part, bytes)); else message.AlternateViews.Add(CreateAlternateView(part, bytes)); From abfe87928a2dee3a18447fc6ca6a86737d9e5c4a Mon Sep 17 00:00:00 2001 From: Vlad Pitaru Date: Wed, 11 Jun 2014 19:47:23 +0300 Subject: [PATCH 2/2] fix messages without body but with attachment send by apple mail parsing the attachment as body because the content disposition is inline --- MessageBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MessageBuilder.cs b/MessageBuilder.cs index d50c5b6..32e495f 100644 --- a/MessageBuilder.cs +++ b/MessageBuilder.cs @@ -356,7 +356,7 @@ internal static void AddBodypart(this MailMessage message, Bodypart part, string // (i.e. spam) mails like to omit content-types so we don't check for that here and just // assume it's text. if (String.IsNullOrEmpty(message.Body) && - part.Disposition.Type != ContentDispositionType.Attachment) { + part.Type == S22.Imap.ContentType.Text) { message.Body = encoding.GetString(bytes); message.BodyEncoding = encoding; message.IsBodyHtml = part.Subtype.ToLower() == "html";