diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m
index 56f6b403f..1f995cbb9 100644
--- a/ActiveSync/SOGoActiveSyncDispatcher.m
+++ b/ActiveSync/SOGoActiveSyncDispatcher.m
@@ -1509,6 +1509,7 @@ void handle_eas_terminate(int signum)
if ([[theResponse headerForKey: @"Content-Type"] isEqualToString:@"application/vnd.ms-sync.multipart"])
{
NSData *d;
+
d = [currentBodyPart fetchBLOBWithPeek: YES];
[s appendFormat: @"%d", i+1];
@@ -1518,9 +1519,15 @@ void handle_eas_terminate(int signum)
else
{
NSString *a;
+
a = [[currentBodyPart fetchBLOBWithPeek: YES] activeSyncRepresentationInContext: context];
- [s appendFormat: @"0-%d", [a length]-1];
+ // Don't send Range when not included in the request. Sending it will cause issue on iOS 10
+ // when downloading attachments. iOS 10 will first report an error upon the first download
+ // and then, it'll work. This makes it work the first time the attachment is downlaoded.
+ if ([[[(id)[aFetch getElementsByTagName: @"Range"] lastObject] textValue] length])
+ [s appendFormat: @"0-%d", [a length]-1];
+
[s appendFormat: @"%@", a];
}
}