Skip to Content
0
Former Member
Nov 27, 2006 at 10:05 AM

save incoming msg from pop3 store folder to folder on pc

67 Views

hello everyone,

I have a problem which in theory should be simple to solve but in practise I can't really seem to figure out how to do it.

Here's the code of how I get the messages to handle each one. What i want to do is put them in a folder on my desktop so I can handle them from there.

(what i do now is get the attachment and save that file alone and deal with it but i'ld like to have the full msg so i can have details on who it's from and who i want to send it to and any other details i might want to process)

Can anyone guide me of how I could do this please?

thanks in advance 😊

Code to connect and get messages:

java.util.Properties props = System.getProperties();

javax.mail.Session session = javax.mail.Session.getInstance(System.getProperties(), null);

javax.mail.Store store = session.getStore("pop3");

store.connect(host, username, password);
javax.mail.Folder folder = store.getFolder("INBOX");

folder.open(javax.mail.Folder.READ_WRITE);

// Get directory
javax.mail.Message messages[] = folder.getMessages();