I am using JavaMail to access and retrieve mails from a mailbox. I wanted to read mails from folders other than Inbox
(say Spam). While browsing through SO, I stumbled upon this question where the accepted answer says :
Don't use POP, use IMAP if you want labels/folders.
Now, can I not browse through all the available folders/labels and read mail from them if I use POP3?
Is there any javadoc supporting this?
Also, I'm using the following snippet to get the folder name
myFolders = store.getDefaultFolder().list(); // or list("*") as pointed out in some other answer
When I use this with POP, the only folder is INBOX. If I use this with IMAP, it throws the following exception after printing INBOX
Exception caught while getting ConfigSettings value javax.mail.MessagingException:
A5 NO [NONEXISTENT] Invalid folder: [Gmail] (Failure);
nested exception is:
com.sun.mail.iap.CommandFailedException:
A5 NO [NONEXISTENT] Invalid folder: [Gmail] (Failure)
Can anyone tell me where I'm going or or how do I achieve my objective of browsing through different folders/labels and read mails from them?
EDIT: Also, if I'm using POP3 is there a way to read and retrieve mails from Spam or other folders/labels?
As described in the javadocs, the POP3 protocol only supports one folder, there's nothing JavaMail can do about that.
I need more details on the problem you're having when using IMAP to list the folders. Can you show the code you use to display the result of the list() call, and can you post the protocol trace?