I am trying to save a whole mailbox onto disk using the JavaMail API (in essence, perform a full backup_. I can successfully read all the relevant folders into memory and then sever the connection to my mail server. What I can’t figure out is how to actually store the folders and/or individual messages if need be on my disk.
I’ve tried searching around and came up with an interesting link (below) but can’t figure this out. Does anyone have any advice on where to get started? I appreciate it, thanks
http://www.oracle.com/technetwork/java/javamail/faq/index.html#serialize
quick note: I tried using a class that contained an ArrayList of type Folder(JavaMail class) and make that serializable, but I still had an exception thrown when I tried to write to disk. I’ve been working on this problem for about two days now and I could use some pointers. Thanks!
You found the FAQ, but you missed this entry:
And, as the FAQ entry you found says, you can’t just serialize the Message objects, let alone the Folder objects.
If all this seems too complicated for you, the simplest approach might be to get an IMAP server that you run on your local machine, then copy the messages from your remote IMAP server to your local IMAP server. The JavaMail FAQ has pointers to IMAP servers you can install locally, and a little web searching will turn up more. JavaMail also comes with a demo program (populate.java) for copying folders.