Javamail和Javafx。阅读并显示邮件嵌入图像 [英] Javamail and Javafx. Read and show mail embedded images

查看:180
本文介绍了Javamail和Javafx。阅读并显示邮件嵌入图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用名为WebEngine(javafx)的控件来显示javamail下载的邮件内容。当内容是纯文本或带有图像src = http链接的html时很好,但是当邮件嵌入了图像(在src中有内容id)时,控件不显示这些图像(cource因为不知道它在哪里)。显示电子邮件的最佳控件是什么?当图像存储在存储器中时,怎么做呢。也许在WebEngine中加载邮件不是一个好主意......

I use control named WebEngine (javafx) to show mail content downloaded by javamail. It's fine when the content is plain text or html with image src=http link, but when mail has embedded images (has content id in src) control dont show this images (of cource because has no idea where is it). What is the best control to show email? How to do it, when image storing in the memory. Maybe load mail in WebEngine is not a good idea...

推荐答案

你需要一个 URLStreamHandler 处理cidURL协议并提供来自相应部分的数据MIME消息。我相信您需要通过创建 URLStreamHandlerFactory <来配置URLStreamHandler / a>并调用 URL.setURLStreamHandlerFactory方法。我记得,诀窍在于,无法获取默认的URLStreamHandlerFactory,以便您的版本可以委托所有其他URL协议的默认版本。

You need a URLStreamHandler that handles the "cid" URL protocol and supplies the data from the appropriate part of the MIME message. I believe you need to configure the URLStreamHandler by creating a URLStreamHandlerFactory and calling the URL.setURLStreamHandlerFactory method. The trick, as I remember, is that there's no way to get the default URLStreamHandlerFactory so that your version can delegate to the default version for all the other URL protocols.

或者,您可以将所有附件保存到磁盘,然后在显示之前处理html内容,将所有cid:references转换为file:references。

Alternatively, you can save all the attachments to disk and then process the html content before it's displayed to convert all cid: references into file: references.

这篇关于Javamail和Javafx。阅读并显示邮件嵌入图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆