在我的应用程序中,我可以使用 MFMailComposer 发送电子邮件。假设如果我的 iPhone 中有 gmail 帐户并且我正在使用我的应用程序发送电子邮件,我可以向其他人发送电子邮件
但假设如果我的 iPhone 中有 yahoo 帐户并且我正在使用我的应用程序发送电子邮件,我将无法发送电子邮件。
我真的不知道有什么问题,MFMailComposer 是否仅使用 gmail 帐户或 m 代码有问题。
请帮我解决这个问题。
以下是我的代码:
-(void)SENDEMAIL
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
NSArray* arr = [[dictUser valueForKey:@"recipients"] componentsSeparatedByString:@","];
NSLog(@"mailcomporeci%@",dictUser);
NSLog(@"arr:%@",arr);
[mailComposer setToRecipients:arr];
//[mailComposer setSubject:[NSString stringWithFormat:@"Scheduled Email %@",arr]];
[mailComposer setSubject:@"Scheduled Email"];
[mailComposer setMessageBody:[dictUser objectForKey:@"message"] isHTML:NO];
mailComposer.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.tabBarController presentModalViewController:mailComposer animated:YES];
[NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(hackMail:) userInfo:mailComposer repeats:NO];
}
}
-(void)hackMail:(NSTimer*)theTimer {
MFMailComposeViewController *mailController = theTimer.userInfo;
UIBarButtonItem *sendBtn = mailController.navigationBar.topItem.rightBarButtonItem;
id targ = sendBtn.target;
[targ performSelector:sendBtn.action withObject:sendBtn];
}
#pragma mark Mail Compose Delegate Methods
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
switch (result)
{
case MFMailComposeResultCancelled:
{
break;
}
case MFMailComposeResultSaved:
{
break;
}
case MFMailComposeResultSent:
{
break;
}
case MFMailComposeResultFailed: {
break;
}
default:
break;
}
[self.tabBarController dismissModalViewControllerAnimated:YES];
}