在Ios上的html电子邮件中显示base64图像

在Ios上的html电子邮件中显示base64图像,第1张

概述我生成一个包含base64图像的html字符串.当MFMailComposeViewController打开时,我会看到生成的电子邮件中的图像.当我发送并打开它时,图像不会显示,只有空方块. 我的代码 - (IBAction)actionShareByEmail:(id)sender { if([MFMailComposeViewController canSendMail]) 我生成一个包含base64图像的HTML字符串.当MFMailComposeVIEwController打开时,我会看到生成的电子邮件中的图像.当我发送并打开它时,图像不会显示,只有空方块.

我的代码

- (IBAction)actionShareByEmail:(ID)sender {    if([MFMailComposeVIEwController canSendMail])    {        MFMailComposeVIEwController *picker = [[MFMailComposeVIEwController alloc] init];        picker.mailComposeDelegate = self;        Nsstring* subject = @"Environments List with qrcode";        [picker setSubject:subject];        [picker setMessageBody:[manager getHTMLWithEnvironments:nil] isHTML:YES];        [self presentVIEwController:picker animated:YES completion:nil];    }}-(Nsstring*)getHTMLWithEnvironments:(NSArray*)envDictionnarIEs{    NSMutableString* HTML = [[NSMutableString alloc]init];    [HTML appendString: @"<HTML><body>"];    for (NSDictionary *d in self.arEnvironments) {        UIImage* qrcode = [QRCodeGenerator qrImageForString:[d objectForKey:@"env_name"] imageSize:200.0];//Works fine        NSData *imageData = UIImagePNGRepresentation(qrcode);        Nsstring *encodedString = [imageData base64EncodedStringWithOptions:NSDataBase64EnCoding64CharacterlineLength];        [HTML appendString: [Nsstring stringWithFormat:@"<H3>%@</h3><img src=\"data:image/png;base64,%@\" wIDth=\"200\" height=\"200\" alt=\"test\" /></br></br>",[d objectForKey:KEY_ENV_name],encodedString]];    }    [HTML appendString: @"</HTML><body>"];    return HTML;}

如何正确显示图像?

解决方法 看起来对内联图像的支持很低 – 主要是由于安全问题.

在下面的第二个问题中链接到Campaign Monitor提供了更多信息.

更多信息:

> Send a base64 image in HTML email
> Base64 HTML embedded images not showing when mailed

总结

以上是内存溢出为你收集整理的在Ios上的html电子邮件中显示base64图像全部内容,希望文章能够帮你解决在Ios上的html电子邮件中显示base64图像所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1103010.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存