[已解決]猜我應該有RTFM!使用[MFMailComposeViewController addAttachmentData:mimeType:fileName:]完全解決了我的問題。根本不需要base64編碼:)iPhone:將圖像從圖像選擇器附加到電子郵件不會顯示在窗口
對於任何有興趣的人this question提供了一些關於base64編碼的好信息。
我允許用戶採取或選擇一個圖像,並將其附加到電子郵件。該電子郵件在Mac郵件中發送並傳送完美,但在Windows(Outlook Express & gmail)上圖像不顯示。 Gmail告訴我'轉換無法加載'。
下面是我用來將圖像附加到電子郵件的代碼。它必須與圖像的編碼有關。任何人都可以建議嗎?
非常感謝所有幫助
- (void) createEmail {
// set up the image data.
NSData *imageData = [NSData dataWithData:UIImageJPEGRepresentation(self.imageToUpload, 1.0)];
NSString *base64String = [imageData base64EncodedString];
NSString *emailBodyString = [NSString stringWithFormat:@"<html><body><img src='data:image/jpeg;base64,%@'></body></html>",base64String];
// create the email modal
NSArray *recipients = [[NSArray alloc] initWithObjects:@"[email protected]",nil];
MFMailComposeViewController *emailDialog = [[MFMailComposeViewController alloc] init];
emailDialog.mailComposeDelegate = self;
[emailDialog setToRecipients:recipients];
[emailDialog setSubject:@"Time Sheet Submission from iPhone App"];
[emailDialog setMessageBody:emailBodyString isHTML:YES];
[self presentModalViewController:emailDialog animated:YES];
[emailDialog release];
[recipients release];
}
剛發現我必須等兩天才能夠接受我的回答,然後就會回來做。感謝titaniumdecoy – bennythemink