Is it possible to embed an inline image in HTML email using MFMailComposeViewController?

纵然是瞬间 提交于 2019-12-08 06:31:51

问题


Is it possible to embed a reference to an image in an HTML email sent via MFMailComposeViewController on iPhone OS 3.0?

(void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename

doesn't seem to provide any way of either setting or reading the Content-ID header for an attachment, but is there some way to make this work?

I have seen apps that do this, but they're probably using SKPSMTPMessage...


回答1:


I believe you can use an HTML tag in the email's body to achieve what you're looking for. It's not common, but the img's src attribute can actually be set to base-64 encoded image data. For instance, you can say "<img src='data:image/gif;base64,R0lGODlhUAAPAKIA......'>" and embed the image data inline.

Here's an article with more information: https://web.archive.org/web/20140819061025/http://www.sweeting.org/mark/blog/2005/07/12/base64-encoded-images-embedded-in-html

I know for a fact that this works in Mobile Safari, but I've never used it in Mail. It seems like it would work - I'm sure they use WebKit to render the HTML email messages as well.

Good luck!



来源:https://stackoverflow.com/questions/1146796/is-it-possible-to-embed-an-inline-image-in-html-email-using-mfmailcomposeviewcon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!