关于使用java在电子邮件中显示图像的疑问?

时间:2021-05-22 21:21:13

I am working mail sending part in my project. My requirement is to generate an image and append it with mail content(using tag). Once the mail has been sent, image should be deleted in application server. After mail sent, two scenarios are happening

Scenario 1 :
When i open the mail first time, it is asking for download pictures. I clicked to download pictures and the image getting displayed in the mail. After that, i close the mail(a popup window came for save changes yes or no.. i gave no) and deleted the image in application server. Now again when i try to open the mail second time(this time image is deleted in application server), same thing it is asking download pictures and after click image get displayed.

我正在邮件发送我的项目的一部分。我的要求是生成一个图像并附加邮件内容(使用标记)。邮件发送后,应在应用程序服务器中删除图像。邮件发送后,发生了两种情况。场景1:当我第一次打开邮件时,它要求下载图片。我点击下载图片,图片显示在邮件中。之后,我关闭邮件(弹出窗口来保存更改是或否..我没有)并删除应用程序服务器中的图像。现在再次当我尝试第二次打开邮件时(此时图像在应用程序服务器中被删除),同样的事情是要求下载图片和点击图像后显示。

Scenario 2 :
Before open the mail first time, i deleted the image in application server and then opened the mail first time(image in application server is deleted now). It is asking for download pictures, when i click download pictures, image is not getting display in the mail.

场景2:在第一次打开邮件之前,我删除了应用程序服务器中的图像,然后第一次打开邮件(现在删除了应用程序服务器中的图像)。它要求下载图片,当我点击下载图片时,图像没有显示在邮件中。

Please help me to sort out the scenario 2. How to display the image when we open mail first time after deletion in application server?

请帮我梳理一下场景2.如何在应用服务器删除后第一次打开邮件时显示图像?

1 个解决方案

#1


Why don't you attach the image to the message? This way it's not going anywhere.

为什么不将图像附加到邮件中?这样它就不会去任何地方。

You need to:

你需要:

  • Attach the image file to the letter
  • 将图像文件附加到字母

  • Assign a content-id to that file by using Content-ID: header
  • 使用Content-ID:标头为该文件分配content-id

  • Refer it by cid: in tags, like: <img src="cid:myfile@somewhere.net">.
  • 通过cid:在标签中引用它,例如:关于使用java在电子邮件中显示图像的疑问?

See http://www.ietf.org/rfc/rfc2392.txt

#1


Why don't you attach the image to the message? This way it's not going anywhere.

为什么不将图像附加到邮件中?这样它就不会去任何地方。

You need to:

你需要:

  • Attach the image file to the letter
  • 将图像文件附加到字母

  • Assign a content-id to that file by using Content-ID: header
  • 使用Content-ID:标头为该文件分配content-id

  • Refer it by cid: in tags, like: <img src="cid:myfile@somewhere.net">.
  • 通过cid:在标签中引用它,例如:关于使用java在电子邮件中显示图像的疑问?

See http://www.ietf.org/rfc/rfc2392.txt