开发者

how to remove cc,bcc in MailComposerViewController? [closed]

开发者 https://www.devze.com 2022-12-09 00:43 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist

Closed 9 years ago.

Improve this question 开发者_运维技巧

i am using MailComposerViewController from apple site.but when i send my message with empty cc,bcc field it gives error. it asks to fill that field .how can i send without cc, bcc with empty field . bcos it is optional to users.any help?


I'm not sure what it is you're missing, but here you have something that might help you:

-Make sure that you're implementing the MFMailComposeViewControllerDelegate Delegate protocol.

-Here you have a snippet of code that works for me:

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];

And here you have the delegate method

#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;
}
}

I hope this helps, good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消