开发者

Easy way to open the Mail application with an pre-defined message subject and body?

开发者 https://www.devze.com 2022-12-31 21:21 出处:网络
In my app the user generates text content. I want to enab开发者_StackOverflowle the user to launch the Mail application, which then should contain a specified subject and message body. Like: You write

In my app the user generates text content. I want to enab开发者_StackOverflowle the user to launch the Mail application, which then should contain a specified subject and message body. Like: You write a poem in my app and then want to send it to your new girlfriend. So you tap a mail icon and the Mail app opens, containing already an subject and message body with your poem inside.

Someone said there is a kind of URL mechanism for that?


You can use MFMailComposeViewController for sending the mail.

-(void)OpenMail{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"my new poem"];
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
}

emailBody is string which contains the poem.

All the best.


Apple URL Scheme Reference: Mail Links lists all your options.

Or you use MFMailComposeViewController.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号