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

问题描述

|| 我正在尝试发送带有嵌入代码(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 电子邮件应用程序打开,但不显示正文。任何想法?     

解决方法

        在包含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]];
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...