如何在MailComposerViewController中删除cc,bcc?

时间:2009-10-19 04:45:09

标签: iphone

我在苹果网站上使用MailComposerViewController。但是当我发送空消息时 cc,bcc字段给出错误。它要求填写该字段。我可以发送没有cc,bcc与空字段。用户可以选择bcos吗?有帮助吗?

1 个答案:

答案 0 :(得分:0)

我不确定你错过了什么,但在这里你有一些可以帮到你的东西:

- 确保您正在实施MFMailComposeViewControllerDelegate委托协议。

- 这里有一段适合我的代码:

MFMailComposeViewController * mc = [[MFMailComposeViewController alloc] initWithNibName:nil bundle:nil];
mc.mailComposeDelegate = self;  
[mc setToRecipients:[NSArray arrayWithObject:self.selectedRecipientEmail]];
NSString * subject = [NSString stringWithFormat:NSLocalizedString(@"Mail subject", nil)];       
[mc setSubject: subject];
[mc setMessageBody: [self composeMessageBodyAsHTML] isHTML:YES];
[self presentModalViewController:mc animated:YES];
[mc release];

在这里你有委托方法

#pragma mark MFMailComposeViewControllerDelegate

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {

switch (result)
{
    case MFMailComposeResultCancelled:
        // Do something
        break;
    case MFMailComposeResultSaved:
        message = NSLocalizedString(@"Saved! The email was successfully saved", @"Email saved message");
        // Do something
        break;
    case MFMailComposeResultSent:
        // Do something
        break;
    case MFMailComposeResultFailed:
        // Do something
        break;
    default:
        // Do something
        break;
}
}

我希望这有帮助,祝你好运!