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];
开发者_JAVA技巧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:first@example.com?cc=second@example.com,third@example.com&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.
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:@"AAA@BBB.com",nil]];
[self presentModalViewController:mail animated:YES];
}
[mail release];
And
see my answer
Best of luck.
精彩评论