Java Reference
In-Depth Information
throws FolderNotFoundException , MessagingException
public abstract Folder [] list ( String pattern )
throws FolderNotFoundException , MessagingException
public Folder [] listSubscribed ( String pattern )
throws FolderNotFoundException , MessagingException
The first method returns an array listing the folders that this folder contains. The second
method returns an array listing all the subscribed folders that this folder contains.
The third and fourth methods repeat these first two, except they allow you to specify a
pattern. Only folders whose full names match the pattern will be in the returned array.
The pattern is a string giving the name of the folders that match. However, the string
can contain the % character, which is a wildcard that matches any sequence of characters
not including the hierarchy separator, and *, which matches any sequence of characters
including the hierarchy separator.
Checking for Mail
The getMessageCount() method returns the number of messages in this folder:
public abstract int getMessageCount ()
throws FolderNotFoundException , MessagingException
This method can be invoked on an open or closed folder. However, in the case of a closed
folder, this method may (or may not) return -1 to indicate that the exact number of
messages isn't easily available.
The hasNewMessages() method returns true if new messages have been added to the
folder since it was last opened (not since the last time you checked!):
public abstract boolean hasNewMessages ()
throws FolderNotFoundException , MessagingException
The getNewMessageCount() method uses a slightly different approach for determining
how many new messages there are. It checks the number of messages in the folder whose
RECENT flag is set:
public int getNewMessageCount ()
throws FolderNotFoundException , MessagingException
Unlike hasNewMessages() , getNewMessageCount() can be invoked on either an open
or a closed folder. However, in the case of a closed folder, getNewMessageCount() may
return -1 to indicate that the real answer would be too expensive to obtain.
The getUnreadMessageCount() method is similar but returns the number of messages
in the folder that do not have a SEEN flag set:
public int getUnreadMessageCount ()
throws FolderNotFoundException , MessagingException
Search WWH ::




Custom Search