A message class is not serializable, so you cannot save its object in a file. I tried to extract the important parts to call the constructor, but it depends on other classes that are not serializable. Is there another way?
One option is to use the mbox local storage provider . Otherwise, you can use javax.mail.internet.MimeMessage.writeTo (OutputStream) to store the message in the file system and javax.mail.internet.MimeMessage (Session, InputStream) to create a message from the file system.