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

发布于 2024-12-02 22:21:53 字数 1011 浏览 3 评论 0原文

在 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

我哪里错了

感谢您的任何建议!

HTML mail with an embedded image in gmail - with the following email body - just spits out the exact text. It does not show what's inside the "body" tags.

This is the content of the mail:

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

Where am I going wrong?

Thanks for any suggestion!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

卸妝后依然美 2024-12-09 22:21:53

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

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

Date: Fri, 2 Dec 2011 06:57:55 GMT
Message-Id: <[email protected]>
Content-Type: multipart/related; boundary="=-blabla"; type="multipart/alternative"
From: Some sender <[email protected]>
To: Me <[email protected]>
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:[email protected]"/>
<p>
</body></html>

--=-blabla
Content-ID: <[email protected]>
Content-Disposition: inline; filename="image.png"
Content-Type: image/png; name="image.png"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAA9YAAAE2CAMAAACz7PorAAADAFBMVEUAAAC9...

I've followed the instructions in question 4018709 and it worked nicely. To sum it up, you need the content-ids for the attachment to be formatted like message IDs (which in turn are formatted like email addresses - with an @ and a domain), and have the content ID value in the MIME part header of the image enclosed in angle brackets (like you already do).

So a sample email may look like this:

Date: Fri, 2 Dec 2011 06:57:55 GMT
Message-Id: <[email protected]>
Content-Type: multipart/related; boundary="=-blabla"; type="multipart/alternative"
From: Some sender <[email protected]>
To: Me <[email protected]>
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:[email protected]"/>
<p>
</body></html>

--=-blabla
Content-ID: <[email protected]>
Content-Disposition: inline; filename="image.png"
Content-Type: image/png; name="image.png"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAA9YAAAE2CAMAAACz7PorAAADAFBMVEUAAAC9...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文