문제

if I save a Message object content to a file using the writeTo method, is it possible recreate the object from that file content?

I know a Message has much more information than the one saved with the writeTo method, like the store, the folder and so on.. but I'm not interested to these information.

Should I parse the file in order to retrieve the information and set every field in a new Message object? Or is there an easier way?

도움이 되었습니까?

해결책

The javax.mail.internet.MimeMessage(Session, InputStream) constructor can be used to parse a MIME message.

try (FileInputStream in = new FileInputStream("foo.eml")) {
        MimeMessage msg = new MimeMessage((Session) null, in);
        //...
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top