participate


JavaMail - Can I serialize Message objects?
<<   Back to Forum  |   Give us Feedback
This topic has 4 replies on 1 page.
vasu_y
Posts:14
Registered: 3/25/98
Can I serialize Message objects?   
Nov 4, 2001 2:41 PM

 
Hi,
I have a need to serialize Message objects.
So I thought of extending MimeMessage and serializing it(by implementing java.io.Serializable interface).

Is it fine to serialize the Message object?

To me, it looks like there may be some reason why Message class (or for that matter MimeMessage) didn't implement Serializable interface.

Any comments from Gurus?

Thanks,
Vasu
 
agnesjuhasz
Posts:12
Registered: 10/10/97
Re: Can I serialize Message objects?   
Apr 4, 2002 5:12 AM (reply 1 of 4)  (In reply to original post )

 
Hi,
Now I have the same problem, need to serialize javax.mail.internet.MimeMessage.
I tried your idea before, extended the MimeMessage class and implementing the Serializable interface. It doesn't work.
Have you found solution since ?
I should greatly appreciate if you could help.

Thanks,
Agnes
 
kohinoor1
Posts:7
Registered: 4/7/02
Re: Can I serialize Message objects?   
Apr 8, 2002 2:13 AM (reply 2 of 4)  (In reply to #1 )

 
Hi,This is Avanish from MNC software bangalore..developing similar functinality of sending MIME message object throgh serialization..i Guess by implementing the Serializable we can serialize and send the object but the problem is It loses some of its envelop and header information from tthe mail...If any one is able to send the serialized MIME MEssage withous lose of nay information please let me ASAP...
thanks and regards...pleaze let me know how can i help you more...
reply me immediately at bloom122@yahoo.com
Any further discussion or clarification at yahoo messenger at bloom122@yahoo.com id..
hope to see ur quite response ASAp.
Avanish
 
kohinoor1
Posts:7
Registered: 4/7/02
Re: Can I serialize Message objects?   
Apr 8, 2002 2:13 AM (reply 3 of 4)  (In reply to #1 )

 
Hi,This is Avanish from MNC software bangalore..developing similar functinality of sending MIME message object throgh serialization..i Guess by implementing the Serializable we can serialize and send the object but the problem is It loses some of its envelop and header information from tthe mail...If any one is able to send the serialized MIME MEssage withous lose of nay information please let me ASAP...
thanks and regards...pleaze let me know how can i help you more...
reply me immediately at bloom122@yahoo.com
Any further discussion or clarification at yahoo messenger at bloom122@yahoo.com id..
hope to see ur quite response ASAp.
Avanish
 
agnesjuhasz
Posts:12
Registered: 10/10/97
Re: Can I serialize Message objects?   
Apr 8, 2002 2:30 AM (reply 4 of 4)  (In reply to #3 )

 
Hi Avanish,

I could resolve the serialization by this way

// on the client side
MimeMessage mimemessage = new MimeMessage((javax.mail.Session)null);
// do what you need
...
// put the content of mimemessage into encoded String what is Serializable
ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.writeTo(baos);
byte[] bytearray = baos.toByteArray();
Base64Encoder encoder = new Base64Encoder();
String base64encodedmessage = encoder.encode(bytearray);

// On the server side
// decode the received string
Base64Decoder decoder = new Base64Decoder();
byte[] bytearray = decoder.decodeBuffer(base64encodedmessage );
ByteArrayInputStream bais = new ByteArrayInputStream(bytearray);

mailprops.setProperty("mail.from",sender);
Session session = Session.getInstance(mailprops,null);
session.setDebug(debug);

MimeMessage mimemessage = new MimeMessage(session,bais);

Hope this helps.
Agnes
 
This topic has 4 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 29
  • Guests : 132

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums