简体   繁体   English

读取 Email 的文本文件转换为 Javamail MimeMessage

[英]Read text file of Email convert to Javamail MimeMessage

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).我有一个电子邮件原始来源的文本文件(直接从 gmail 复制,如果你点击“查看原文”,你会看到它)。 I want to read this file in and convert it into a MimeMessage.我想读入这个文件并将其转换为 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.如果您对原因感到好奇,我已经设置了 JavaMaildir,并且需要在其收件箱中填充电子邮件以进行测试。 I've never really dealt with reading files and all this, so any help would be great thanks.我从来没有真正处理过阅读文件和所有这些,所以任何帮助都会非常感谢。

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);
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM