读取Email的文本文件转换为Javamail MimeMessage [英] Read text file of Email convert to Javamail MimeMessage

查看:235
本文介绍了读取Email的文本文件转换为Javamail MimeMessage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个电子邮件原始来源的文本文件(如果你单击查看原始文件,你会看到它直接从gmail复制)。我想读取这个文件并将其转换为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). I want to read this file in and convert it into a MimeMessage.

如果您对原因感到好奇,我设置了JavaMaildir,并需要填充它的收件箱用于测试目的的电子邮件。我从来没有真正处理过阅读文件和所有这些,所以任何帮助都会非常感谢。

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.

推荐答案

这样的事情应该是work:

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

这篇关于读取Email的文本文件转换为Javamail MimeMessage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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