Bill
Bill

Reputation: 3823

iPhone not returning to application after calling eMail send

I am sending an email from within my iPhone application. The eMail page pops up ok, I click on the Send button, the iPhone plays a whoosh sound, and the eMail actually arrives at the recipient.

Unfortunately, the mail dialog still sits there unresponsive, and the only option - to click the home button - kills the app.

Is there something else that needs to be specified to close the eMailMessage view?

MFMailComposeViewController *eMailMessage;
NSArray *toAddress;

if ([MFMailComposeViewController canSendMail]) {
    toAddress = [NSArray arrayWithObject:@"[email protected]"];
    eMailMessage = [[MFMailComposeViewController alloc] init];
    [eMailMessage setToRecipients:toAddress];
    [eMailMessage setSubject:@"Notification"];
    [eMailMessage setMessageBody:@"Performed by ..." isHTML:NO];
    [self presentModalViewController:eMailMessage animated:YES];
    [eMailMessage release];
}

Upvotes: 0

Views: 173

Answers (1)

Tom Irving
Tom Irving

Reputation: 10059

You need to set the delegate and implement this method:

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

    [controller dismissModalViewControllerAnimated:YES];
}

Upvotes: 1

Related Questions