栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在电子邮件中嵌入图像

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在电子邮件中嵌入图像

如您所知,作为电子邮件传递的所有内容都必须文本化。

  • 您必须创建包含多部分/ mime消息的电子邮件。
  • 如果要添加物理图像,则该图像必须使用base 64编码并分配了Content-ID(cid)。如果是URL,则
    <img />
    标记就足够了(图像的url必须链接到Source ID)。

典型的电子邮件示例如下所示:

From: foo1atbar.netTo: foo2atbar.netSubject: A simple exampleMime-Version: 1.0Content-Type: multipart/related; boundary="boundary-example"; type="text/html"--boundary-exampleContent-Type: text/html; charset="US-ASCII"... text of the HTML document, which might contain a URIreferencing a resource in another body part, for examplethrough a statement such as:<IMG SRC="cid:foo4atfoo1atbar.net" ALT="IETF logo">--boundary-exampleContent-Location: CID:somethingatelse ; this header is disregardedContent-ID: <foo4atfoo1atbar.net>Content-Type: IMAGE/GIFContent-Transfer-Encoding: base64R0lGODlhGAGgAPEAAP/////ZRaCgoAAAACH+PUNvcHlyaWdodCAoQykgMTk5LiBVbmF1dGhvcml6ZWQgZHVwbGljYXRpb24gcHJvaGliaXRlZC4A etc...--boundary-example--

正如你所看到的,

Content-ID:<foo4atfoo1atbar.net>
ID匹配到
<IMG>
SRC="cid:foo4atfoo1atbar.net"
。这样,客户端浏览器会将您的图像呈现为内容而不是附件。

希望这可以帮助。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/442944.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号