PokiTheKing
PokiTheKing

Reputation: 69

MFMailComposeViewController change to recipients

Hi I would like to enable the user to send e-mail to different e-mail address it depends on the bout ton selected in the table view - All from same view. My problem is changing the e-mail address of the recipient each time i tried a few things like putting the e-mail address in a String which updates depending on the bout ton pressed but i was not able to get the e-mail address to the to: Tab in the composer. I am able to fix a spesific e-mail address but i want the to: tab to change each time it is a different recipient. Any help would be appreciated - My current code which returns blank e-mail address is below. (Mail is my String receiving the correct e-mail address each time).

-(void)displayComposerSheet 
{
    MFMailComposeViewController *mailComposerVC = [[MFMailComposeViewController alloc] init];
    mailComposerVC.mailComposeDelegate = self;

    [mailComposerVC setSubject:@"Iphone App"];

    NSArray *toRecipients = [NSArray arrayWithContentsOfFile:mail]; 

    [mailComposerVC setToRecipients:toRecipients];

    NSString *BodyText = @"My Name Is:    \n My Phone Number Is:     \n Please Help With:    \n";
    [mailComposerVC setMessageBody:BodyText isHTML:NO];

    [self presentModalViewController:mailComposerVC animated:YES];
}

Upvotes: 0

Views: 944

Answers (1)

Gravemind
Gravemind

Reputation: 55

What is your toRecipients?

Why don't you just do:

NSString *email1 = @"[email protected]"

NSString *email2 = @"[email protected]"

//if logic
NSArray *toRecipients = [NSArray arrayWithObject:email1];
//if logic
NSArray *toRecipients = [NSArray arrayWithObject:email2];

Upvotes: 1

Related Questions