如何在MFMailComposeViewController for iPhone中将图像嵌入到HTML中 [英] How to embed image in html in MFMailComposeViewController for iPhone

查看:141
本文介绍了如何在MFMailComposeViewController for iPhone中将图像嵌入到HTML中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在html表格中嵌入一些我想用MFMailComposeViewController发送的小图片。在做了一些搜索之后,我发现几乎每个人都在暗示Matt Gallagher的NSData + Base64类在Base64encoding中对照片进行编码并将其嵌入到html中。虽然它看起来可以在iPhone和某些电子邮件服务器上工作,但 Gmail和Yahoo不会以这种方式显示嵌入的图像。提到这个问题这里以及。

我想知道是否有人有更好的解决方案。我不想在网上上传照片,并把链接放在html代码中。我希望将图像附加到电子邮件中,并在html文本,表格中显示为内嵌图像。 解决方案

不幸的是,目前无法按照您的意愿完成这项工作。 HTML电子邮件中的内嵌图像使用单独的MIME部分,这些部分通过消息正文中的content-id引用。 MFMailComposeViewController不允许您控制消息的MIME结构,并且不允许添加内联引用的内容部分。



将图像数据嵌入< img> 标记作为base64可以用于某些组合 - 这部分是电子邮件客户端的功能,部分是用于呈现它的浏览器的一部分,但正如您已经注意到的,它不是广泛的便携式。

I am trying to embed a bunch of small images in an html table which I want to send using MFMailComposeViewController. After doing some search I figured out almost everyone is suggesting "NSData+Base64 by Matt Gallagher" class to encode the photo in Base64encoding and embedding it into html. While it looks to work on iPhone and with some email servers but Gmail and Yahoo do not show the images embedded this way. This problem is mentioned here as well.

I was wondering if anyone has a better solution for this. I don't want to upload photos on the web and put the link in the html code. I would like the image to be attached to the email and show up as an inline image within html text,table,...

解决方案

This unfortunately cannot be done currently in the way that you desire. Inline images in HTML email use separate MIME parts that are referenced via a content-id from the body of the message. MFMailComposeViewController doesn't give you control over the MIME structure of the message, and doesn't let you add inline referenced content parts.

Embedding image data into <img> tags as base64 can work on some combinations-- it's partly a function of email client and partly of the browser ultimately used to render it, but as you have noticed, it's not broadly portable.

这篇关于如何在MFMailComposeViewController for iPhone中将图像嵌入到HTML中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆