From 82178fd6ceb5c4cb9acb10a4be06c022c895de7a Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 11 Feb 2015 08:31:32 -0500 Subject: [PATCH] Initial patch from tfu for bug #3055 --- ActiveSync/SOGoMailObject+ActiveSync.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ActiveSync/SOGoMailObject+ActiveSync.m b/ActiveSync/SOGoMailObject+ActiveSync.m index e7797dfeb..a1b8c8434 100644 --- a/ActiveSync/SOGoMailObject+ActiveSync.m +++ b/ActiveSync/SOGoMailObject+ActiveSync.m @@ -227,6 +227,10 @@ struct GlobalObjectId { type = [part valueForKey: @"type"]; subtype = [part valueForKey: @"subtype"]; + // Don't select an attachment as body + if ([[[part valueForKey: @"disposition"] valueForKey: @"type"] isEqualToString: @"attachment"]) + continue; + if ([type isEqualToString: @"text"] && [subtype isEqualToString: @"html"]) htmlKey = key; else if ([type isEqualToString: @"text"] && [subtype isEqualToString: @"plain"]) @@ -439,7 +443,7 @@ struct GlobalObjectId { { s = [s htmlToText]; } - + d = [s dataUsingEncoding: NSUTF8StringEncoding]; } else if ([type isEqualToString: @"multipart"]) @@ -734,7 +738,13 @@ struct GlobalObjectId { len = [content length]; [s appendString: @""]; - [s appendFormat: @"%d", preferredBodyType]; + + // Set the correct type if client requested text/html but we got text/plain + if (preferredBodyType == 2 && nativeBodyType == 1) + [s appendString: @"1"]; + else + [s appendFormat: @"%d", preferredBodyType]; + [s appendFormat: @"%d", truncated]; [s appendFormat: @""];