こちらのソースコードを見つけて、それを使ってメールを送ってみました。「MFMailComposeResultSent」メッセージは正常に取得できましたが、実際のメールは送信されません。なぜ機能しないのかわかりません。また、NSData から画像を添付しましたが、mailcomposeview に表示されません。このコードの何が問題になっていますか? 本当は添付画像付きのネイティブメールアプリを呼び出せばいいのですが、ネイティブアプリを添付画像付きで呼び出す方法はないと聞きました。私のコードの何が問題なのか教えてください。問題 1: mailcomposeview からメールが送信されない、問題 2: 添付画像が表示されない。ベスト : 画像が添付されたネイティブ メール アプリを実行しています。私は喜んであなたの答えを待っています。どうも。
-(void) sendMail
{
NSLog(@"Mail");
MFMailComposeViewController *mfMailView = [[MFMailComposeViewController alloc]init];
NSData *imgData = UIImagePNGRepresentation(imgPreview.image);
mfMailView.mailComposeDelegate = self;
[mfMailView addAttachmentData:imgData mimeType:@"image/png" fileName:@"Me.png"];
//also tried this
//[mfMailView addAttachmentData:imgData mimeType:@"image/png" fileName:@"Me"];
[mfMailView setSubject:@"TE~st"];
[mfMailView setMessageBody:@"Download Me~!" isHTML:YES];
[self presentModalViewController:mfMailView animated:YES];
}
-(void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result) {
case MFMailComposeResultCancelled:
NSLog(@"cancel?");
break;
case MFMailComposeResultSaved:
NSLog(@"saved?");
break;
case MFMailComposeResultSent:
NSLog(@"Sent succed");
[controller dismissModalViewControllerAnimated:YES];
break;
case MFMailComposeResultFailed:
NSLog(@"sent failue");
NSLog(@"%@",error);
break;
default:
break;
}
}