views:

32

answers:

1

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];
}
+1  A: 

You need to set the delegate and implement this method:

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

    [controller dismissModalViewControllerAnimated:YES];
}
Tom Irving
Hi Tom - it would have been more accurate if you'd said "set the setMailComposeDelegate", but I managed to work that out in the end. Thanks.
Bill
Sorry :( sometimes I assume people will know what I'm talking about when I've not quite switched to a non-programming mindset.
Tom Irving