【问题标题】:Display base64 images in a html email on Ios在 Ios 上的 html 电子邮件中显示 base64 图像
【发布时间】:2014-12-20 01:14:44
【问题描述】:

我生成了一个包含 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;
}

如何才能正确显示图片?

【问题讨论】:

标签: html objective-c email uiimage base64


【解决方案1】:

看起来对内嵌图像的支持很低 - 主要是由于安全问题。

下面第二个问题中指向Campaign Monitor 的链接提供了更多信息。

更多信息:

【讨论】:

    猜你喜欢
    • 2019-12-14
    • 2014-05-03
    • 2020-08-20
    • 2013-09-13
    • 2013-04-20
    • 1970-01-01
    • 2018-09-30
    • 2013-09-21
    • 2011-08-06
    相关资源
    最近更新 更多