Java Reference
In-Depth Information
CHAPTER 8
Folders
So far, we've worked mostly with the INBOX folder. This is the default folder in which
most mail resides until the user filters or saves it into some other folder. On some sys‐
tems, it may actually reside in a file called INBOX. On other systems, it may be called
something different. Nonetheless, you can always access it from the JavaMail API using
the name INBOX.
Most mail programs allow you to organize your messages into different folders. These
folders are hierarchical; that is, a folder may contain another folder. In particular, in the
IMAP protocol, servers store the messages in different folders from which clients re‐
trieve and manipulate the messages as necessary. POP servers, by contrast, generally
send all the messages to the user when the user connects and rely on the client to store
and manage them. The primary advantage of the IMAP approach over POP is that it
allows users to easily access their entire email archives from multiple client machines.
The JavaMail API represents IMAP-like folders as instances of the abstract Folder class:
public abstract class Folder extends Object
This class declares methods for requesting named folders from servers, deleting mes‐
sages from folders, searching for particular messages in folders, listing the messages in
a folder, and so forth. Most of these methods are declared abstract. When you ask a
session, a store, or a folder to give you one of the folders it contains, it will give you an
instance of a concrete subclass appropriate for the protocol in use: IMAP, POP, mbox,
or whatever. The reference implementation of the JavaMail API knows how to do these
operations only for IMAP servers. However, some third-party implementations provide
these operations in local mailbox folders stored on the client's filesystem as well.
 
Search WWH ::




Custom Search