How can I make a Message object from a text file / input stream (in RFC-822 format)?

Eric Aubourg

If your text file input stream is istr, just do:

javax.mail.internet.MimeMessage msg = new javax.mail.internet.MimeMessage(sess, istr);

where sess is a JavaMail session. If you need to create a session (for instance, you just want to parse the text file using Message methods):

class MyAuthenticator 
  extends javax.mail.Authenticator {}
javax.mail.Authenticator auth = 
  new MyAuthenticator();
java.util.Properties prop = 
  new java.util.Properties();
javax.mail.Session sess = 
      prop, auth);
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact