0

I am using iPhone in-App email feature to send email thru my app. The email goes fine but I am having hard time trying to figure out how to retrive email addresses to which the email was sent. Here is my code:

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self; 
[picker setSubject:@"Test"];

// Fill out the email body text
NSString *emailBody = [NSString stringWithFormat:@"This is a test data"];

[picker setMessageBody:emailBody isHTML:YES];

picker.navigationBar.barStyle = UIBarStyleBlack; 

[self presentModalViewController:picker animated:YES];
[picker release];

Is there any way to retrive those email addresses from this function:

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

Thanks!

user315603
  • 57
  • 1
  • 4

3 Answers3

1

Looking through the MFMailComposeViewController documentation I see only methods to set the recipients.

I think that this is probably a very deliberate move by Apple to prevent the misuse of personal information, much in the same way that Apple does not allow a developer to fetch a user's mobile number programmatically.

jessecurry
  • 22,068
  • 8
  • 52
  • 44
0

No you cannot. This is private information.

You could make your own e-mail entry form and then pre-fill to field of the MFMailComposeViewController using - (void)setToRecipients:(NSArray*)toRecipients. But you cannot sure that the user doesn't change the address once MFMailComposeViewController is shown.

This answer to a similar question suggests using custom IMAP libary like Mailcore instead of built in MFMailComposeViewController.

Community
  • 1
  • 1
texmex5
  • 4,354
  • 1
  • 26
  • 28
  • Good point. It is indeed private info which Apple might want to protect. So, I guess I'll have to handle sending of emails thru my backend code. Only problem would be to grab emails from already existing contacts. Mailcore seems like a good alternative... I'll check that out. Well, Thanks a lot! – user315603 May 13 '10 at 15:51
0

I don't think that's possible. There are no public properties in a MFMailComposeViewController besides the delegate, and it only seems to have setter methods and no getters.

Pyro2927
  • 1,112
  • 9
  • 18