I'm trying to include an image in the body of an HTML email sent from an iPad. It seems impossible. I have tried to use the CID approach, but it seems that in iOS it is not possible to get/set the CID of attachments.
I've also tried to embed the image with src="data:image/png;base64, blahblahblah"
. When you compose the mail it seems to work, but nothing appears when the mail is received.
Any ideas?
More Detail:
We are not looking for a solution where the JPEG/PNG is attached at the bottom of an email. That's easy to do with [composer addAttachmentData:mimeType:fileName:]
.
We are looking for a solution where the image is embedded inline in an HTML-formatted email. You could wrap a link around that IMG tag, so that when the recipient clicks the IMG, he/she will be linked out to the app's iTunes page.
The HTML <img> tag is used to embed an image in a web page. Images are not technically inserted into a web page; images are linked to web pages. The <img> tag creates a holding space for the referenced image. The <img> tag is empty, it contains attributes only, and does not have a closing tag.
Download the NSData+base64
category from github.
Then do the following:
NSData *imageData = [NSData dataWithContentsOfFile:pathInDocumentDirectory(imagePath)];
NSString *base64String = [imageData base64EncodedString];
NSString *imageString = [NSString stringWithFormat:@"data:image/png;base64,%@", base64String];
Finally, put the imageString
in the HTML body where you want this image to appear.
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With