Java Reference
In-Depth Information
As the name implies, the messages in the array are placed at the end of this folder.
The copyMessages() method copies messages from this folder into a specified folder
given as an argument:
public void copyMessages ( Message [] messages , Folder destination ) throws
IllegalStateException , FolderNotFoundException , MessagingException
The copied messages are appended to the destination folder. They are not removed from
the source folder. To move a message, you have to copy it from the source to the desti‐
nation, delete it from the source folder, and finally expunge the source folder.
To delete a message from a folder, set its Flags.Flag.DELETED flag to true . To physically
remove deleted messages from a folder, you have to call its expunge() method:
public abstract Message [] expunge () throws MessagingException ,
IllegalStateException , FolderNotFoundException
After a message has been expunged, there may still be Message objects that refer to it.
In this case, almost any method call on such an object, except isExpunged() and get
MessageNumber() , will throw an exception.
Subscriptions
Some implementations allow you to subscribe to particular folders. This would be most
appropriate for an NNTP provider, where a typical server offers thousands of news‐
groups, but the typical user will want to retrieve messages from a few dozen of these, at
most. Each newsgroup would be represented as a Folder object. A subscription to the
newsgroup's Folder indicates that the user wants to retrieve messages from that news‐
group:
public boolean isSubscribed ()
public void setSubscribed ( boolean subscribe )
throws FolderNotFoundException , MethodNotSupportedException ,
MessagingException
Subscriptions are sometimes also used in IMAP to specify a subset of a user's folders
that need to be cached locally or prefetched.
If a provider doesn't support subscription, setSubscribed() throws a MethodNotSup
portedException and isSubscribed() returns false .
Listing the Contents of a Folder
There are four methods to list the folders that a folder contains:
public Folder [] list ()
throws FolderNotFoundException , MessagingException
public Folder [] listSubscribed ()
Search WWH ::




Custom Search