我正在尝试发送包含嵌入式gif图像的多部分/相关html电子邮件。该电子邮件是使用Oracle PL / SQL生成的。我的尝试失败了,图片显示为红色X(在Outlook 2007和yahoo邮件中)
我已经发送HTML电子邮件已有一段时间了,但是我现在的要求是在电子邮件中使用多个gif图像。我可以将它们存储在我们的一台Web服务器上并只是链接到它们,但是许多用户的电子邮件客户端不会自动显示它们,因此需要更改设置或手动为每封电子邮件下载它们。
因此,我的想法是嵌入图像。我的问题是:
片段:
MIME-Version: 1.0
To: [email protected]
BCC: [email protected]
From: [email protected]
Subject: Test
Reply-To: [email protected]
Content-Type: multipart/related; boundary="a1b2c3d4e3f2g1"
--a1b2c3d4e3f2g1
content-type: text/html;
<html>
<head><title>My title</title></head>
<body>
<div style="font-size:11pt;font-family:Calibri;">
<p><IMG SRC="cid:my_logo" alt="Logo"></p>
... more html here ...
</div></body></html>
--a1b2c3d4e3f2g1
Content-Type: image/gif;
Content-ID:<my_logo>
Content-Transfer-Encoding: base64
Content-Disposition: inline
[base64 image data here]
--a1b2c3d4e3f2g1--
非常感谢。
顺便说一句:是的,我已经验证了base64数据是正确的,因为我可以将图像嵌入html本身(使用相同的算法创建标头数据)并在Firefox / IE中查看图像。
我还要注意,这不是针对垃圾邮件的,电子邮件是每天发送给特定客户的。内容是数据驱动的,而不是广告。
尝试直接插入它,这样您可以在电子邮件中的不同位置插入多个图像。
<img src="data:image/jpg;base64,{{base64-data-string here}}" />
并为了使该帖子对其他人有用:如果您没有base64数据字符串,请从以下图像文件轻松创建一个:http : //www.motobit.com/util/base64-decoder-encoder.asp。
电子邮件源代码看起来像这样,但我真的无法告诉您该边界对象是什么:
To: [email protected]
Subject: ...
Content-Type: multipart/related;
boundary="------------090303020209010600070908"
This is a multi-part message in MIME format.
--------------090303020209010600070908
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#ffffff" text="#000000">
<img src="cid:part1.06090408.01060107" alt="">
</body>
</html>
--------------090303020209010600070908
Content-Type: image/png;
name="moz-screenshot.png"
Content-Transfer-Encoding: base64
Content-ID: <part1.06090408.01060107>
Content-Disposition: inline;
filename="moz-screenshot.png"
[base64 image data here]
--------------090303020209010600070908--
//编辑:哦,我只是意识到,如果您从我的帖子中插入第一个代码片段来用thunderbird编写电子邮件,那么thunderbird会自动将html代码更改为与我的帖子中的第二个代码几乎相同。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句