user542584
user542584

Reputation: 2689

mfmailcomposeviewcontroller code does not work

I had a tab view controller within which I used to call the code below and it was working fine. I removed the tab and made it a simple navigation controller, but then the same code stopped working. The mail view does not show up. The button action does nothing. What could be wrong with below code

 if ([MFMailComposeViewController canSendMail]) {
    MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
    mailViewController.mailComposeDelegate = self;
    [mailViewController setSubject:[NSString stringWithFormat:@"test"]];
    [mailViewController setMessageBody:@"" isHTML:NO];
    [mailViewController setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
    [self presentModalViewController:mailViewController animated:YES];
    [mailViewController release];}

Upvotes: 0

Views: 361

Answers (1)

Bill Burgess
Bill Burgess

Reputation: 14154

From your comments above, I'm pretty sure that is your reason. You can't just import the header files to get the MFMailCompose to work. You have to implement the MFMailComposeViewControllerDelegate and the methods that go along with that for it to present the mail view correctly.

Here is a link to a nice tutorial that should help you out getting the methods configured correctly.

In-App Email Tutorial

Upvotes: 1

Related Questions