Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaMail: storing Messages  RSS feed

 
Andris Jekabsons
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a "nice" way to store Message object for easy retrieval later?
I am connecting to a mail server to retrieve emails, which I need to store in DB for later processing. Unfortunately Message (POP3Message in my case) is not serializable. Also, the "writeTo()" method does not really work for me, because it outputs the Message as a string, and if I wanted to reconstruct the Message object, I would need to parse it manually.
Does anybody know a way to achieve this?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on what you want to do with the message later on, the getAllHeaderLines and getContent methods might provide you with all the information you need.
 
Andris Jekabsons
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! I ended up converting all Headers from getAllHeaders() method to a custom serialized counterpart (so that I could store them as a single object), and getting the content from the getContent() method and serializing various its parts.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!