Question

I'm currently composing an HTML-Mail using MFMailComposer. Everything like Background Color etc. is working quite fine, I can even embed images inline which are located under an online URL. But when I want to embed an locally stored UIImage everything is messed up. Therefore I'm converting the data to base64 and use the image-tag as follows

<img src='data:image/png;base64,%@'>

In the preview on the device everything is shown properly, but on my computer in the mail-app there is only the placeholder question mark image, when I view the source of the mail all there seems to be send is

<img src="cid:(null)">

Also I'm able to successfully log the base64 encoded data on the device, it just simply doesn't make it's way to the server or down from there. Attaching the image is not a solution as I NEED the image to be inline and not at the end of the mail :(

UPDATE:

Here's are the lines I use to embed the image into HTML inline:

[body appendFormat:@"<p><b><img src='data:image/png;base64,%@'/></b></p>",[[NSData dataWithData:UIImagePNGRepresentation([dict objectForKey:@"graphImage"])] base64EncodedString]];
Was it helpful?

Solution

It's not possible to embed inline images (I've spend days on the problem).

Oh, how I wish it were....

OTHER TIPS

Are you using the following:

NSString *emailBody = [NSString stringWithFormat:@"<img src='data:image/png;base64,%@' alt='testing' />",base64String];
[picker setMessageBody:emailBody isHTML:YES];

It is possible. There was a breaking change in iOS: There are no "new lines" allowed in the base64 data.

see this thread: Base64 HTML embedded images not showing when mailed

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top