Gmail中的HTML电子邮件 - 嵌入图片

时间:2011-09-03 11:13:02

标签: gmail html-email

在Gmail中嵌入图像的HTML邮件 - 使用以下电子邮件正文 - 只是吐出确切的文本。它没有显示“body”标签内的内容。

这是邮件的内容:

Content-Type: multipart/related;

boundary="bananarepublic12345"

This is a multipart message in MIME format.

--banana12345republic

Content-Type: text/html; charset=ISO-8859-1

Content-Transfer-Encoding: 7bit


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" 
      "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head> 
     <title>testing embedded image</title>
</head>
<body bgcolor="#000">
    <h1> Testing Embedded Image</h1>
    <img src="cid:mambo" alt="ALTERNATE TEXT" >
</body>
</html>

--bananarepublic12345

Content-Type: image/jpeg; name=big-image1.jpg

Content-Transfer-Encoding: base64

Content-ID: <mambo>

Content-Disposition: inline;

filename="big-image1.jpg"

/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ...//2Q%3D%3D

我要去哪里错误

感谢您的任何建议!

1 个答案:

答案 0 :(得分:7)

我已按照问题4018709中的说明进行操作,效果很好。总结一下,您需要将附件的内容ID格式化为消息ID(其格式类似于电子邮件地址 - 带有@和域),并且在MIME部分标题中具有内容ID值。括号内的图像(就像你已经做过的那样)。

因此,示例电子邮件可能如下所示:

Date: Fri, 2 Dec 2011 06:57:55 GMT
Message-Id: <201112020657.pB26vttQ010231@geek.co.il>
Content-Type: multipart/related; boundary="=-blabla"; type="multipart/alternative"
From: Some sender <some-sender@geek.co.il>
To: Me <me@geek.co.il>
Subject: HTML content with embedded images
MIME-Version: 1.0

--=-blabla
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html><body>
<h1>Header</h1>
<h2><a href=3D"http://geek.co.il">link</a></h2>
<p>
<img border=3D"0" =
src=3D"cid:some.random.id@geek.co.il"/>
<p>
</body></html>

--=-blabla
Content-ID: <some.random.id@geek.co.il>
Content-Disposition: inline; filename="image.png"
Content-Type: image/png; name="image.png"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAA9YAAAE2CAMAAACz7PorAAADAFBMVEUAAAC9...