I'm trying to send an HTML email with embedded UIImages.
This is my code:
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];
When the Email Modal View Controller comes up I see the images just fine. But when I tried to view this email on my Mac and on my iPhone and the images comes out empty.