在 iPhone 上通过 [UIApplication sharedApplication] 发送带有 html 标签的电子邮件

发布于 11-10 09:53 字数 695 浏览 8 评论 0原文

我正在尝试发送一封带有嵌入代码(html 片段)的电子邮件,但电子邮件正文为空。

        NSURL *url = [NSURL URLWithString: me.emailUrl];
        [[UIApplication sharedApplication] openURL:url];

        NSLog(@"SnapShotViewController->infoAction: %@", url);

原始字符串看起来像这样。

最终的字符串看起来像这样。

mailto:?subject=SnapShot&body=%3Ciframe%20style%3D'width:320px;height:320px;border:0px'%20src%3D'http://snapserve.alphakanal.de/embed%3Fkey%3Db500bb47-e14d -405f-a70b-9779dbb8ce21'%3E%3C/iframe%3E

电子邮件应用程序打开但不显示正文。有什么想法吗?

I am trying to send an email with an embed code (html snippet) but the email body is empty.

        NSURL *url = [NSURL URLWithString: me.emailUrl];
        [[UIApplication sharedApplication] openURL:url];

        NSLog(@"SnapShotViewController->infoAction: %@", url);

The original string looks like this.

<iframe style='width:320px;height:320px;border:0px' src='http://snapserve.alphakanal.de/embed?key=b500bb47-e14d-405f-a70b-9779dbb8ce21'>

The final string looks like this.

mailto:?subject=SnapShot&body=%3Ciframe%20style%3D'width:320px;height:320px;border:0px'%20src%3D'http://snapserve.alphakanal.de/embed%3Fkey%3Db500bb47-e14d-405f-a70b-9779dbb8ce21'%3E%3C/iframe%3E

The email app opens up but does not show the body. Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扎心2024-11-17 09:53:02

在包含 HTML 的 NSString 上使用 - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding ,如下所示:

NSString *html = @"<html><body><b>test</b></body></html>";
NSString *email = [NSString stringWithFormat:@"mailto:?subject=SnapShot&body=%@",[html stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];

Use - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding on your NSString containing the HTML, like so:

NSString *html = @"<html><body><b>test</b></body></html>";
NSString *email = [NSString stringWithFormat:@"mailto:?subject=SnapShot&body=%@",[html stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文