How to stop embedded images in email being displayed as attachments by GMail?(如何阻止电子邮件中的嵌入图像被 GMail 显示为附件?)
问题描述
我正在发送带有嵌入图像(作为附件)的 HTML 电子邮件,并且图像在 GMail 中按预期显示.但是,它们也显示为电子邮件下的附件.有谁知道如何避免这种情况,即我只希望它们在电子邮件中而不是作为附件列出.我使用了内容处置:内联".我正在使用 Spring 和 JavaMail.
I am sending HTML emails with embedded images (as attachments) and the images display as expected in GMail. However they also show up as attachments under the email. Does anyone know how to avoid this i.e. I want them in the email only and not listed as attachments. I have used "Content-Disposition: inline". I am using Spring and JavaMail.
这就是我的邮件最终的样子.谁能看出什么问题?
Here is what my mails end up like. Can anyone see whats wrong?
Delivered-To: ...
...
Subject: ...
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_0_1248835444.1288246311187"
------=_Part_0_1248835444.1288246311187
Content-Type: multipart/related;
boundary="----=_Part_1_592250078.1288246311197"
------=_Part_1_592250078.1288246311197
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<html>
<body>
<p><img src="cid:a0"/></p>
</body>
</html>
------=_Part_1_592250078.1288246311197
Content-Type: image/x-png
Content-Transfer-Encoding: base64
Content-Disposition: inline
Content-ID: <a0>
iVBORw0KGgoAAAANSUhEUgAAAPAAAABQCAYAAAAnSfh8AAAACXBIWXMAAC4jAAAuIwF4pT92AAAA
...
Qcz8hzyUxqGHjkNbsY4Df5iBg6OIwafQHBxFjP8PAIwl43uhncLdAAAAAElFTkSuQmCC
------=_Part_1_592250078.1288246311197--
------=_Part_0_1248835444.1288246311187--
推荐答案
可以按照以下步骤从 GMail 中获取这样的邮件正文:
It is possible to get such a mail body out of GMail by following these steps:
- 在 Gmail 实验室中启用由 Kent T 插入图片"
- 写一封邮件并将图片嵌入到邮件中
- 给自己发邮件
- 打开邮件.在右上角,按带有向下箭头的图片(在回复旁边),然后按显示原件".在那里您会找到此类邮件的示例.
我这样做并得到以下结果,其中图像未列为附件.也许这个邮件正文可以帮助您使用 Spring 和 JavaMail 创建正确的邮件:
I did this and got following result, where the image is not listed as attachement. Maybe this mail body helps you to create a proper mail with Spring and JavaMail:
MIME-Version: 1.0
...
Subject: ...
From: ...
To: ...
Content-Type: multipart/related; boundary=000e0cd62fb69a9c280493a7a1c0
--000e0cd62fb69a9c280493a7a1c0
Content-Type: multipart/alternative; boundary=000e0cd62fb69a9c250493a7a1bf
--000e0cd62fb69a9c250493a7a1bf
Content-Type: text/plain; charset=ISO-8859-1
[image: abc.png]
--000e0cd62fb69a9c250493a7a1bf
Content-Type: text/html; charset=ISO-8859-1
<img src="cid:ii_12bf191c5eab934e" alt="abc.png" title="abc.png"><br>
--000e0cd62fb69a9c250493a7a1bf--
--000e0cd62fb69a9c280493a7a1c0
Content-Type: image/png; name="abc.png"
Content-Transfer-Encoding: base64
Content-ID: <ii_12bf191c5eab934e>
X-Attachment-Id: ii_12bf191c5eab934e
iVBORw0KGgoAAAANSUhEUgAAAJ4AAADLCAIAAAAQpL1oAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
...
这篇关于如何阻止电子邮件中的嵌入图像被 GMail 显示为附件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何阻止电子邮件中的嵌入图像被 GMail 显示为附件?
基础教程推荐
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01