Vishnu
Vishnu

Reputation: 2243

MessageUI framework issue for UITextField contents are not displayed

I've included messageUI framework in my app for sending mail.It contains five UITextField where the values entered by user should be displayed in mail body. Here is my code

if ([MFMailComposeViewController canSendMail])
{
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];

    mailer.mailComposeDelegate = self;

    [mailer setSubject:[NSString stringWithFormat:@"Appointment From Mr/Mrs. %@",text1.text]];

    NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", nil];
    [mailer setToRecipients:toRecipients];



    NSString *emailBody =[NSString stringWithFormat:@"Name :%@\nDate: %@\nPreferred Time Slot: %@\nE-Mail:%@\nSpecific Requests:",text1.text,text2.text,text3.text,text4.text,text5.text]; 

    [mailer setMessageBody:emailBody isHTML:NO];


    [self presentModalViewController:mailer animated:YES];

    [mailer release];
}

The issue i'm facing is that all the four text field values are displayed only the fifth text field values are not displayed..Any idea?...am i missing anything?...

Upvotes: 0

Views: 125

Answers (2)

Vishnu
Vishnu

Reputation: 2243

Edit the following line of code

 NSString *emailBody =[NSString stringWithFormat:@"Name :%@\nDate: %@\nPreferred Time Slot: %@\nE-Mail:%@\nSpecific Requests:%@",text1.text,text2.text,text3.text,text4.text,text5.text]; 

you will get your requirements...Dont forget to use resignFirstresponder to hide keyboard after u entered text...

Upvotes: 1

rckoenes
rckoenes

Reputation: 69479

You only have four %@ in the form at string, thus the last parameter supplied to the format method is ignored.

Change the format string to have five parameters:

NSString *emailBody =[NSString stringWithFormat:@"Name :%@\nDate: %@\nPreferred Time Slot: %@\nE-Mail:%@\nSpecific Requests:%2",text1.text,text2.text,text3.text,text4.text,text5.text]; 

Upvotes: 2

Related Questions