I have been trying to serialize a MimeMessage instance, but as I read on web it is not possible. What I want to achieve with serializing a MimeMessage instance is that I want to hash that instance and send it along mail itself. What I coded so far is this:
MimeMessage message = new MimeMessage(session);
//...setting up content of MimeMessage
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("object.ser")));
oos.writeObject(message);
oos.close();
It compiles on GlassFish server, but I get a runtime error when I try to use service. It says:
exception
java.io.NotSerializableException: javax.mail.internet.MimeMessage
I tried it to do in this way; yet it didn't work, either:
Object obj = new Object();
obj = (Object)message;
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("object.ser")));
oos.writeObject(obj);
oos.close();
Is there any way to achieve serializing a MimeMessage instance or to go around and hack it in some other way?