如何在iOS中的电子邮件的HTML主体中嵌入图像 [英] How to embed an image in the HTML body of an email in iOS
问题描述
我正在尝试将图像包含在从iPad发送的HTML电子邮件的正文中。看起来不可能我试图使用CID方法,但似乎在iOS中,不可能获取/设置附件的CID。
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.
我也试图嵌入图像与 src =data:image / png; base64,blahblahblah
。当您撰写邮件时,似乎可以正常工作,但收到邮件后不会显示。
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.
任何想法?
更多细节:
我们不是在电子邮件底部附加JPEG / PNG的解决方案。这很容易与 [composer addAttachmentData:mimeType:fileName:]
。
我们正在寻找在HTML格式的电子邮件中嵌入图片 inline 的解决方案。您可以围绕该IMG标签包装链接,以便收件人点击IMG时,他/她将被链接到应用程序的iTunes页面。
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.
推荐答案
从 github
Download the NSData+base64
category from github.
然后执行以下操作:
NSData *imageData = [NSData dataWithContentsOfFile:pathInDocumentDirectory(imagePath)];
NSString *base64String = [imageData base64EncodedString];
NSString *imageString = [NSString stringWithFormat:@"data:image/png;base64,%@", base64String];
最后,将 imageString
身体,你想要这个图像出现。
Finally, put the imageString
in the HTML body where you want this image to appear.
希望它有帮助!
这篇关于如何在iOS中的电子邮件的HTML主体中嵌入图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!