1
votes

I am using this code for mail

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];

picker.mailComposeDelegate = self;

NSString *msgTitle = @"Sample Title";

[picker setSubject:msgTitle];

NSArray *toRecipients =[[NSArray alloc] init];

NSArray *ccRecipients =[[NSArray alloc] init];

NSArray *bccRecipients =[[NSArray alloc] init];

[picker setToRecipients:toRecipients];

[picker setCcRecipients:ccRecipients];

[picker setBccRecipients:bccRecipients];

NSString *sum = @"The Email Body string is here";

NSString *emailBody;

emailBody = [NSString stringWithFormat:@"%@",sum];

[picker setMessageBody:emailBody isHTML:YES];

[self presentModalViewController:picker animated:YES];

[picker release];

it works,

i want to know,is it required to modify

-(void)launchMailAppOnDevice { NSString *recipients = @"mailto:[email protected][email protected],[email protected]&subject=Hello from California!"; NSString *body = @"&body=It is raining in sunny California!";

NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body]; email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]]; }

if yes then how i modify in this method.

Please help me.

1

1 Answers

0
votes

If email address is given statically and displayed in To address.

You can use this code,

   MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
   mail.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail]) {    
    [mail setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];

    [self presentModalViewController:mail animated:YES];

}

 [mail release];

And

see my answer

Best of luck.