2016-12-19 16 views
0

私のアプリ内からMFMailComposeViewControllerで電子メールを送信できません。電子メールが送信されたというログメッセージが表示されますが、決してアカウントには送信されません。私は、ネイティブのメールアプリケーションに移動し、送信トレイから送信する必要があります。ネイティブアプリ内でさえ失敗した方法を教えてくれるエラーはありません。私はプライバシー設定などを見逃していますか?これはもともと正常に動作しました。 iOS 10アップデート後に問題が発生しています。は、MFMailComposeViewControllerで電子メールを送信できません。

-(void)sendEmail:(NSString*)email order:(NSMutableArray *)orderA{ 
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init]; 
if ([MFMailComposeViewController canSendMail]) 
{ 

    mail.mailComposeDelegate = self; 
    [mail setSubject:[NSString stringWithFormat:@"Order #%@ order", storeNum]]; 
    [mail setMessageBody:[orderA description] isHTML:NO]; 
    [mail setToRecipients:@[email]]; 
    [self presentViewController:mail animated:YES completion:nil]; 
} 
else 
{ 
    NSLog(@"This device cannot send email"); 
} 
} 
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error 
{ 
switch (result) { 
    case MFMailComposeResultSent: 
     NSLog(@"You sent the email."); 
     break; 
    case MFMailComposeResultSaved: 
     NSLog(@"You saved a draft of this email"); 
     break; 
    case MFMailComposeResultCancelled: 
     NSLog(@"You cancelled sending this email."); 
     break; 
    case MFMailComposeResultFailed: 
     NSLog(@"Mail failed: An error occurred when trying to compose this email"); 
     break; 
    default: 
     NSLog(@"An error occurred when trying to compose this email"); 
     break; 
} 

[self dismissViewControllerAnimated:YES completion:nil]; 
} 

答えて

0
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error 
{ 
switch (result) { 
    case MFMailComposeResultSent: 
     NSLog(@"You sent the email."); 
     break; 
    case MFMailComposeResultSaved: 
     NSLog(@"You saved a draft of this email"); 
     break; 
    case MFMailComposeResultCancelled: 
     NSLog(@"You cancelled sending this email."); 
     break; 
    case MFMailComposeResultFailed: 
     NSLog(@"Mail failed: An error occurred when trying to compose this email"); 
     break; 
    default: 
     NSLog(@"An error occurred when trying to compose this email"); 
     break; 
} 

[self dismissViewControllerAnimated:YES completion:NULL]; 
} 


-(IBAction)mailClick:(id)sender{ 

if ([MFMailComposeViewController canSendMail]) 
{ 
    MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init]; 
    mail.mailComposeDelegate = self; 
    [mail setSubject:@"Message from XYZ"]; 
    // [mail setMessageBody:@"Here is some main text in the email!" isHTML:NO]; 
    [mail setToRecipients:@[@"[email protected]"]]; 

    [self presentViewController:mail animated:YES completion:NULL]; 
} 
else 
{ 

    NSLog(@"This device cannot send email"); 
} 

} 
+0

あなただけの私のコードをコピーして、その答えとして、それを提出しましたか? – iDev

関連する問題