从HTML页面发送邮件,身体中的图像 [英] Sending mail from HTML page with image in the body

查看:269
本文介绍了从HTML页面发送邮件,身体中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当按下按钮时,我必须打开外观组合框,机身应该包含特定DIV的图像。
我正在使用html2canvas来捕获图像,通过mailto我可以触发一个Outlook的组合邮件实例,但似乎mailto是简单的纯文本,不支持在邮箱中嵌入图像。



任何想法,想法?

解决方案

TL; DR:你不能这样做。






你可以使用数据URI方案将图像嵌入到HTML中。如果电子邮件MIME类型为 text / html ,则可以执行相同操作。您将必须使用合适的编码对您的图像进行编码(例如: base64 )。



例如: p>

 < img src =data:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4 // 8 / w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg ==alt =红点/>  



您不能在中添加HTML身体部分 mailto:网址 body 参数的内容根据 RFC 2368


特殊的hnamebody表示相关的hvalue是消息的正文。 bodyhname应包含消息的第一个文本/纯文本部分的内容。 mailto URL主要用于生成实际上是自动处理内容的短文本消息(例如邮件列表的订阅消息),而不是一般的MIME主体。


所以如果你使用一个编码HTML的URL作为 mailto的 body 参数: URL,这里发生了什么:



 < a href =至mailto:?!email@domain.com主题=检查%20this%20out&放大器;身体=%3CP%3EHi%3C%2FP%3E%3Cimg%20src%3D%22data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4%2F%2F8 %2Fw38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg%3D%3D%22%20%%3D%22Red%20dot%22%20%2F%3E"写电子邮件< / a>  

/ div>



结果:




I have to bring up the outlook compose box when a button is pressed and the body should contain the image of a specific DIV. I am using html2canvas to capture the image, with mailto i am able to fire a outlook compose mail instance but seems mailto is for simple plain text and is not supporting to embed image in the mailbox.

Any ideas, thoughts?

解决方案

TL;DR: You cannot do this.


You can use Data URI Scheme to embed an image in HTML. If an emails MIME type is text/html you can do the same. You will have to encode your image with a suitable encoding (e.g.: base64).

For example:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

However, you cannot include HTML in the body part of the mailto: URL. The content of the body parameter is considered plain-text as per RFC 2368.

The special hname "body" indicates that the associated hvalue is the body of the message. The "body" hname should contain the content for the first text/plain body part of the message. The mailto URL is primarily intended for generation of short text messages that are actually the content of automatic processing (such as "subscribe" messages for mailing lists), not general MIME bodies.

So if you use a URL encoded HTML as the body parameter of a mailto: URL, here is what happens:

<a href="mailto:email@domain.com?subject=Check%20this%20out!&body=%3Cp%3EHi%3C%2Fp%3E%3Cimg%20src%3D%22data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4%2F%2F8%2Fw38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg%3D%3D%22%20alt%3D%22Red%20dot%22%20%2F%3E">Write Email!</a>

Result:

这篇关于从HTML页面发送邮件,身体中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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