9

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.

Yottagray
  • 2,552
  • 5
  • 32
  • 43

1 Answers1

24

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);
...
bora.oren
  • 3,439
  • 3
  • 33
  • 31
Eugene Kuleshov
  • 31,461
  • 5
  • 66
  • 67
  • Thank you. I know I must sound really slow here, but if I have the text document in question at the root of my project folder, is there a way to instantiate a File with the document's relative path? – Yottagray Jul 08 '11 at 15:47