diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index ce843cdc4..00c662f1e 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -1898,39 +1898,7 @@ static NSString *userAgent = nil; newText = [text htmlByExtractingImages: extractedBodyParts]; if ([extractedBodyParts count]) [self setText: newText]; - - int i; - for (i = 0 ; i < [extractedBodyParts count] ; i++) { - NSMutableDictionary *currentInfo; - NSString *filename, *mimeType, *bodyId, *encoding; - NSData *body; - NGMimeBodyPart *extractedBodyPart; - NGMimeContentDispositionHeaderField *contentDisposition; - extractedBodyPart = [extractedBodyParts objectAtIndex:i]; - encoding = [extractedBodyPart encoding]; - contentDisposition = [[NGMimeContentDispositionHeaderField alloc] initWithString: [extractedBodyPart headerForKey: @"content-disposition"]]; - - mimeType = [[extractedBodyPart contentType] stringValue]; - bodyId = [[extractedBodyPart contentId] stringValue]; - filename = [contentDisposition filename]; - - [contentDisposition release]; - - currentInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: - filename, @"filename", - mimeType, @"mimetype", - bodyId, @"bodyId", - nil]; - // TODO REMOVE data-cke-saved-src ? - if (encoding && [encoding rangeOfString:@"base64"].location != NSNotFound) - body = [[[extractedBodyParts objectAtIndex:i] body] dataByDecodingBase64]; - else - body = [[extractedBodyParts objectAtIndex:i] body]; - - [self saveAttachment: body - withMetadata: currentInfo]; - } } map = [self mimeHeaderMapWithHeaders: _headers @@ -1961,6 +1929,51 @@ static NSString *userAgent = nil; } } + if (_extractImages) + { + int i; + for (i = 0 ; i < [extractedBodyParts count] ; i++) { + NSMutableDictionary *currentInfo; + NSString *filename, *mimeType, *bodyId, *encoding; + NSData *body; + NGMimeBodyPart *extractedBodyPart; + NGMimeContentDispositionHeaderField *contentDisposition; + + extractedBodyPart = [extractedBodyParts objectAtIndex:i]; + if (extractedBodyPart && [extractedBodyPart headerForKey: @"content-disposition"]) { + encoding = [extractedBodyPart encoding]; + contentDisposition = [[NGMimeContentDispositionHeaderField alloc] initWithString: [extractedBodyPart headerForKey: @"content-disposition"]]; + + if (encoding + && [extractedBodyPart contentType] + && [extractedBodyPart contentId] + && [contentDisposition filename]) { + + mimeType = [[extractedBodyPart contentType] stringValue]; + bodyId = [[extractedBodyPart contentId] stringValue]; + filename = [contentDisposition filename]; + currentInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: + filename, @"filename", + mimeType, @"mimetype", + bodyId, @"bodyId", + nil]; + + if ([[extractedBodyParts objectAtIndex:i] body]) { + if (encoding && [encoding rangeOfString:@"base64"].location != NSNotFound) + body = [[[extractedBodyParts objectAtIndex:i] body] dataByDecodingBase64]; + else + body = [[extractedBodyParts objectAtIndex:i] body]; + + [self saveAttachment: body + withMetadata: currentInfo]; + } + } + [contentDisposition release]; + } + + } + } + return message; }