I\'m trying to unit test a method which processes javax.mail.Message instances.
I am writing a converter to change emails which arrive in different form
After a few tests, I finally successfully loaded a message using the MimeMessage(Session, InputStream) public constructor (as opposed to the Folder-based protected one cited in the other response).
import java.io.FileInputStream;
import java.io.InputStream;
import javax.mail.internet.MimeMessage;
public class LoadEML {
public static void main(String[] args) throws Exception {
InputStream is = new FileInputStream(args[0]);
MimeMessage mime = new MimeMessage(null, is);
System.out.println("Subject: " + mime.getSubject());
}
}