JavaMail API: Problems Getting Folder Names

I am writing an application that can communicate with IMAP Servers and will allow the user to
access multiple folders on the server and access and manipulate the different messages that are in these folders.
 I am testing my application using my personal gmail account and am having difficulty getting the names of the folders in the account.  I know that there are 8 different folders in the account
but when I run the code below I get no folder names listed and the number of folders is stated as 1.  

Folder[] folders= store.getPersonalNamespaces();
for(int i=0; i<folders.length; i++)
          System.out.println("Folder #" + i + " is: " + folders[i].getName());
          System.out.println("The folder size is: " + folders.length);

Open in new window

Who is Participating?
Kevin CrossChief Technology OfficerCommented:
Folder[] folders = store.getDefaultFolder().list();

That works for me on AOL and GMAIL IMAP.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.