Re: Using imap for reading messages from folders other than Inbox
Posted By:
Christopher_Koenigsberg
Posted On:
Monday, March 28, 2005 04:42 PM
My guess is that unless someone has the answer already written down here, you will have to use IMAP-specific methods (e.g. cast your "Store" to the Sun "IMAPStore class", if possible).... to experiment and find out about the namespaces you can access, and how to ask for them, among the folders on the server.
The "Store" interface in the JavaMail API has to work on the lowest common denominator, which is POP. POP servers only have the one DefaultFolder available, with no "namespaces", but IMAP servers can offer multiple namespaces for accessing folders owned by the same user, by other users, also shared folders.
A quick look at javadoc e.g. for the Sun IMAPStore class yields interesting possibilities including "getSharedNamespaces()", "getPersonalNamespaces()", "getUserNamespaces", ...
Also for the "getFolder()" method it says, re the "name" parameter, "... name - The name of the Folder. In some Stores, name can be an absolute path if it starts with the hierarchy delimiter. Else it is interpreted relative to the 'root' of this namespace..."