を使用してMFMailComposerViewController
、iOS アプリからメールを送信しています。画像を追加しようとする場合を除いて、メールは機能します。私にとっての画像の問題は、それを使用して取得することです
次のようなものを使用する他の例を見てきました:UIImage *emailImage = [UIImage imageNamed:@"myImageName.png"];
画像を追加します。私の画像は、を使用してデータベーステーブルから取得されます[self.photo objectForKey:kPhotoPictureKey];
// mail
// Email Subject
NSString *emailTitle = @"Join. Download the iPhone app";
// Email Content
NSString *messageBody = @"http://www..com/";
// To address
NSArray *toRecipents = [NSArray arrayWithObject:@""];
UIImageView *mailImage = [[UIImageView alloc] init];
mailImage.image = [UIImage imageNamed:@"1.png"]; // placeholder image
mailImage.file = [self.photo objectForKey:kPhotoPictureKey];
[mailImage loadInBackground];
NSString *messageBody = [NSString stringWithFormat:@"http://www.example.com/<p><b><img src='data:image/png;base64,%@'></b></p>",mailImage.image];
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:toRecipents];
// Present mail view controller on screen
[self presentViewController:mc animated:YES completion:NULL];