使用 openURL 发送邮件的问题
我在使用 openURL 打开邮件客户端时遇到问题。这是代码。
NSString *subject = @"Demo Subject";
NSString *body = @"<html><head>Header</head><body><a href=\"http://example.com\">Here is the demo link</a></body></html>";
NSString *urlString = [NSString stringWithFormat:@"mailto:?&subject=%@&body=%@",subject,body];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
我想,是否需要使用特殊字符进行任何类型的编码,这种编码确实存在,但在示例文本中未显示。
谢谢
I'm facing a issue with opening mail client using openURL. Here is the code.
NSString *subject = @"Demo Subject";
NSString *body = @"<html><head>Header</head><body><a href=\"http://example.com\">Here is the demo link</a></body></html>";
NSString *urlString = [NSString stringWithFormat:@"mailto:?&subject=%@&body=%@",subject,body];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
I guess, is there any kind of encoding needed to use special characters, which is do present, but not shown here in the sample text.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我想你可以用这个
代替 openURL
I think you can use this
instead of openURL
我认为您可以使用
MFMailComposeViewController
为此。这可以帮助您使用此方法支持特殊字符,即
I think you can make use of
MFMailComposeViewController
for this. That can help you to support special characters by using this methodie
尝试了你的代码并得到了问题 [NSURL URLWithString:urlString] 此行返回 nil。
tried your code and got the problem [NSURL URLWithString:urlString] this line returns nil.
我改变这一行检查它,并比较它......
I change in this line check it, and compare it...