我正在使用Xcode 6。
我正在使用MFMailComposerViewController在应用程序中发送电子邮件。
我可以调用MFMailComposerViewController,它提供发送电子邮件的标准接口。
我也可以设置主题。
但我无法设置收件人。
这是我的代码。
if ([MFMailComposeViewController canSendMail]) {
mailComposer = [[MFMailComposeViewController alloc]init];
[mailComposer setSubject:@"PSA Mobile CRM"];
NSArray *toRecipients = [NSArray arrayWithObject:@"abc@mass.uk.net"];
[mailComposer setToRecipients:toRecipients];
mailComposer.mailComposeDelegate = self;
[self presentViewController:mailComposer 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:NULL]; }
我可以发送电子邮件。
但我无法设置setToRecipients
方法。
有人可以帮我解决这个问题吗?