gon*_*ins 1 email iphone nsstring ios
我只是尝试使用此代码发送电子邮件,它似乎工作:
NSString* urlEmail = [NSString stringWithString: @"mailto:foo@example.com?cc=bar@example.com&subject=test%20from%20me!&body=this%20is%20a%20test!"];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: urlEmail]];
Run Code Online (Sandbox Code Playgroud)
唯一的问题是,是否有一个函数可以用来自动转义普通NSString中的所有内容,所以我不必像这样手动写出来?如果没有,我如何使用stringWithFormat而不与字符串中已有的%符号冲突?我基本上希望能够动态追加,主题,身体等.
小智 9
使用MFMailComposeViewController:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setToRecipients:recipients];
[picker setSubject:subject];
[picker setMessageBody:body isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4277 次 |
| 最近记录: |