读取电子邮件的文本文件转换为 Javamail MimeMessage

发布于 2024-11-19 00:50:37 字数 175 浏览 8 评论 0原文

我有一个电子邮件原始来源的文本文件(直接从 gmail 复制,如果您单击“查看原始文件”,您就会看到它)。我想读入该文件并将其转换为 MimeMessage。

如果您好奇为什么,我设置了 JavaMaildir,并且需要用电子邮件填充它的收件箱以进行测试。我从来没有真正处理过阅读文件和所有这些,所以任何帮助将非常感谢。

I have a text file of the original source of an email(just straight copied from gmail if you click on "View Original" you'll see it). I want to read this file in and convert it into a MimeMessage.

If you are curious as to why, I have JavaMaildir set up, and need to populate it's inbox with emails for testing purposes. I've never really dealt with reading files and all this, so any help would be great thanks.

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

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

发布评论

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

评论(1

只想待在家 2024-11-26 00:50:37

像这样的东西应该有效:

InputStream mailFileInputStream = new FileInputStream(...);
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session, mailFileInputStream);
...

Something like this should work:

InputStream mailFileInputStream = new FileInputStream(...);
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session, mailFileInputStream);
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文