1

我正在尝试发送带有嵌入式 UIImages 的 HTML 电子邮件。

这是我的代码:

MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;

    [mailComposer setSubject:NSLocalizedString(@"Subject", @"Default Subject")];

    // Build email body (HTML)
    UIImage *emailImage = [UIImage imageNamed:@"image.png"];
    NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(emailImage)];
    NSString *base64String = [imageData base64EncodedString];
    NSMutableString *emailBody = [[NSMutableString alloc] initWithString:@"<HTML>Hey,<br><br>Here's the image!"];
    [emailBody appendString:[NSString stringWithFormat:@"<img src='data:image/png;base64,%@'></html>",base64String]];
    [mailComposer setMessageBody:emailBody isHTML:YES];
    [delegate.viewController presentModalViewController:mailComposer animated:YES];

当电子邮件模态视图控制器出现时,我看到的图像很好。但是当我试图在我的 Mac 和 iPhone 上查看这封电子邮件时,图像显示为空。

4

0 回答 0