Class Mailboxes
- All Implemented Interfaces:
AutoCloseable
Inspect IMAP mailbox names and attributes returned by Chilkat.Imap.
Chilkat.Mailboxes is a read-only result collection populated by
Chilkat.Imap.MbxList. Applications inspect the returned mailbox
names and attributes but do not directly add, remove, or modify entries. The
class provides indexed access to mailbox flags, selectable status, marked
status, whether child mailboxes exist, and whether child mailboxes may be
created.
Mailbox collection
Receive the read-only list of IMAP mailboxes populated by
Chilkat.Imap.MbxList.
Indexed mailbox access
Use the mailbox count and index-based methods to retrieve each mailbox name in the returned collection.
Mailbox flags
Inspect IMAP flags associated with each mailbox, including standard and server-specific attributes.
Selectable status
Determine whether a mailbox can be selected and opened for message access.
Hierarchy information
Check whether a mailbox has child mailboxes or whether children may be created beneath it.
Marked status
Detect whether a mailbox is marked or unmarked according to the attributes returned by the IMAP server.
Common pattern:
Call Chilkat.Imap.MbxList to populate a
Mailboxes object, loop from 0 to
Count - 1, retrieve each mailbox name, and inspect its flags or
selectable status. Mailbox names are exposed as normal Unicode text; Chilkat
automatically handles modified UTF-7 or IMAP UTF-8 at the protocol level.
For an extended overview, see Mailboxes Class Overview.
</section>
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetCount()Returns the number of mailboxes in this collection.getFlags(int index)Returns a comma-separated list of flags for the mailbox at the zero-based index specified byindex.intgetMailboxIndex(String mbxName)Returns the zero-based index of the mailbox whose name matchesmbxName.getName(int index)Returns the name of the mailbox at the zero-based index specified byindex.getNthFlag(int index, int flagIndex)Returns one flag from a mailbox in the collection.intgetNumFlags(int index)Returns the number of flags associated with the mailbox at the zero-based index specified byindex.booleanReturnstrueif the mailbox at the zero-based index specified byindexcontains the flag named byflagName.booleanhasInferiors(int index)Returnstrueif the mailbox at the zero-based index specified byindexeither has child mailboxes or permits child mailboxes to be created beneath it.booleanisMarked(int index)Returnstrueif the mailbox at the zero-based index specified byindexhas the IMAP\Markedattribute.booleanisSelectable(int index)Returnstrueif the mailbox at the zero-based index specified byindexcan be selected or examined for message access.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Mailboxes
public Mailboxes()Creates a newMailboxesobject.
-
-
Method Details
-
getCount
public int getCount()Returns the number of mailboxes in this collection. An empty collection has a count of0.Mailboxesis a read-only result container populated byImap.MbxList. Applications inspect the returned entries but do not directly add, remove, or modify mailboxes in this object.- Returns:
- the value of the
Countproperty (read-only)
-
getFlags
Returns a comma-separated list of flags for the mailbox at the zero-based index specified byindex.For example:
\HasNoChildren,\Important
To inspect the flags individually, use
andgetNumFlags(int).getNthFlag(int, int)- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getMailboxIndex
Returns the zero-based index of the mailbox whose name matchesmbxName.Pass
mbxNameas a normal Unicode mailbox name. Chilkat automatically handles the protocol-level modified UTF-7 or IMAP UTF-8 representation; the application should not encode the mailbox name manually.The returned index can be used with methods such as
,getName(int), andgetFlags(int).isSelectable(int)- Parameters:
mbxName- thembxNameargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getName
Returns the name of the mailbox at the zero-based index specified byindex.The name is returned as normal Unicode text. Chilkat automatically decodes modified UTF-7 or IMAP UTF-8 mailbox names received from the server and automatically performs the corresponding encoding when the name is passed to an
Imapmethod.The returned name can therefore be passed directly to methods that select, examine, create, rename, delete, copy to, or otherwise operate on a mailbox. Do not manually encode or decode the mailbox name.
- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getNthFlag
Returns one flag from a mailbox in the collection.indexis the zero-based mailbox index.flagIndexis the zero-based flag index within that mailbox.
Call
to determine the number of flags available for the mailbox.getNumFlags(int)- Parameters:
index- theindexargumentflagIndex- theflagIndexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getNumFlags
public int getNumFlags(int index)Returns the number of flags associated with the mailbox at the zero-based index specified byindex.Returns
-1ifindexis outside the valid mailbox-index range. Useto retrieve the individual flags.getNthFlag(int, int)- Parameters:
index- theindexargument- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
hasFlag
Returnstrueif the mailbox at the zero-based index specified byindexcontains the flag named byflagName.Flag-name comparison is case-insensitive. Include the leading backslash when checking an IMAP system flag or mailbox attribute, for example
\Marked,\Noselect, or\HasChildren.- Parameters:
index- theindexargumentflagName- theflagNameargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
hasInferiors
public boolean hasInferiors(int index)Returnstrueif the mailbox at the zero-based index specified byindexeither has child mailboxes or permits child mailboxes to be created beneath it.Important distinction:
\HasNoChildrenmeans that no child mailboxes currently exist. It does not mean that children cannot be created. The IMAP\Noinferiorsattribute means that child mailboxes cannot be created.- Parameters:
index- theindexargument- Returns:
- the result; this method never throws
ChilkatException
-
isMarked
public boolean isMarked(int index)Returnstrueif the mailbox at the zero-based index specified byindexhas the IMAP\Markedattribute.\Markedis a server-provided hint that the mailbox may contain messages added since it was last selected. It is advisory information returned by the mailbox-listing operation.- Parameters:
index- theindexargument- Returns:
- the result; this method never throws
ChilkatException
-
isSelectable
public boolean isSelectable(int index)Returnstrueif the mailbox at the zero-based index specified byindexcan be selected or examined for message access.A mailbox having the IMAP
\Noselectattribute is not selectable, even though it may appear in the mailbox hierarchy and may contain selectable child mailboxes.- Parameters:
index- theindexargument- Returns:
- the result; this method never throws
ChilkatException
-