小编use*_*647的帖子

如何使用MFMailComposeViewController设置ToRecipients

我正在尝试收到我选择发送电子邮件的电子邮件.但我不知道如何setToRecipients我在MFMailComposeViewController视图中选择的用户.

if ([MFMailComposeViewController canSendMail])
    {
        mailer = [[MFMailComposeViewController alloc] init];

        mailer.mailComposeDelegate = self;
        [mailer setSubject:@"A Message from blablabl"];

        NSMutableArray *usersTo = [[NSMutableArray alloc] init];
        toRecipients = usersTo;
        [mailer setToRecipients:toRecipients];

        NSString *emailBody = @"blablablabal";

        [mailer setMessageBody:emailBody isHTML:YES];

        // only for iPad
        // mailer.modalPresentationStyle = UIModalPresentationPageSheet;

        [self presentModalViewController:mailer animated:YES];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" 
                                                        message:@"Your device doesn't support the composer sheet" 
                                                       delegate:nil 
                                              cancelButtonTitle:@"OK" 
                                              otherButtonTitles: nil];
        [alert show];
    }
Run Code Online (Sandbox Code Playgroud)

委托 http://pastie.org/3281814

iphone xcode objective-c mfmailcomposeviewcontroller

8
推荐指数
2
解决办法
1万
查看次数