Mailboxes Chilkat2 Perl Reference Documentation

Chilkat2::Mailboxes

Current Version: 11.7.0

Markdown version of this page for AI tools (v 11.7.0) · all AI docs

Chilkat.Mailboxes

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.

Object Creation

use Chilkat2;

my $mailboxes = Chilkat2::Mailboxes->new;
# or set properties (and RaiseError) at creation:
# my $mailboxes = Chilkat2::Mailboxes->new(VerboseLogging => 1, RaiseError => 1);
my $mailboxes = Chilkat2::Mailboxes->new(Property => $value, ...);

Creates the object. The optional pairs set writable properties (and RaiseError) in order, as if set one by one; an unknown or read-only name croaks. use Chilkat2; loads every class; the Chilkat2/Mailboxes.pm file holds only this class's documentation (perldoc Chilkat2::Mailboxes).

Perl frees the object when its last reference goes (undef $mailboxes, or the variable going out of scope); there is nothing to close. Objects returned by methods are independent and freed the same way. The class may be subclassed (use parent -norequire, 'Chilkat2::Mailboxes';): an object is a blessed hash reference whose hash is free for the subclass's own fields.

my $boolVal = $mailboxes->RaiseError;
$mailboxes->RaiseError($boolVal);

When false (the default), a method that fails returns false (or undef), and the reason is in LastErrorText. When true, it dies with a Chilkat2::Error instead, as DBI does with its RaiseError. Objects returned by a method inherit the value of the object that returned them.

Errors

A Chilkat2::Error stringifies to the failed call's full LastErrorText, and has the methods text, class ('Chilkat2::Mailboxes'), method (the method name) and object. Methods that look something up and find nothing return undef without dying (each such method says so), methods that answer a question (HasMember, IsUnlocked, ...) return a plain boolean, and property reads and writes never fail for Chilkat reasons.

Misuse always croaks, with your file and line, whatever RaiseError is: a wrong number of arguments, a reference or undef where a string or number is expected, an object of the wrong class, an out-of-range integer, a string containing a NUL character, a wide character in a byte string, or a write to a read-only property.

Strings are Perl character strings in both directions (length, regexes and :encoding layers see characters); binary data (BinData) is a byte string. Unlocking: call Chilkat2::Global->new->UnlockBundle('...') once at startup.

Properties

Count
# $intVal is an integer (read-only)
my $intVal = $mailboxes->Count;

Returns the number of mailboxes in this collection. An empty collection has a count of 0.

Mailboxes is a read-only result container populated by Imap.MbxList. Applications inspect the returned entries but do not directly add, remove, or modify mailboxes in this object.

top
DebugLogFilePath
# $strVal is a string
my $strVal = $mailboxes->DebugLogFilePath;
$mailboxes->DebugLogFilePath($strVal);

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

More Information and Examples
top
LastErrorHtml
# $strVal is a string (read-only)
my $strVal = $mailboxes->LastErrorHtml;

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
# $strVal is a string (read-only)
my $strVal = $mailboxes->LastErrorText;

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
# $strVal is a string (read-only)
my $strVal = $mailboxes->LastErrorXml;

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
# $boolVal is a boolean
my $boolVal = $mailboxes->LastMethodSuccess;
$mailboxes->LastMethodSuccess($boolVal);

Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
VerboseLogging
# $boolVal is a boolean
my $boolVal = $mailboxes->VerboseLogging;
$mailboxes->VerboseLogging($boolVal);

If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
# $strVal is a string (read-only)
my $strVal = $mailboxes->Version;

Version of the component/library, such as "10.1.0"

More Information and Examples
top

Methods

GetFlags
# $index is an integer
# $str is a string or undef
my $str = $mailboxes->GetFlags($index);

Returns a comma-separated list of flags for the mailbox at the zero-based index specified by $index.

For example:

\HasNoChildren,\Important

To inspect the flags individually, use GetNumFlags and GetNthFlag.

Returns undef on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.

More Information and Examples
top
GetMailboxIndex
# $mbxName is a string
# $n is an integer
my $n = $mailboxes->GetMailboxIndex($mbxName);

Returns the zero-based index of the mailbox whose name matches $mbxName.

Pass $mbxName as 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, GetFlags, and IsSelectable.

More Information and Examples
top
GetName
# $index is an integer
# $str is a string or undef
my $str = $mailboxes->GetName($index);

Returns the name of the mailbox at the zero-based index specified by $index.

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 Imap method.

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.

Returns undef on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.

More Information and Examples
top
GetNthFlag
# $index is an integer
# $flagIndex is an integer
# $str is a string or undef
my $str = $mailboxes->GetNthFlag($index, $flagIndex);

Returns one flag from a mailbox in the collection.

  • $index is the zero-based mailbox index.
  • $flagIndex is the zero-based flag index within that mailbox.

Call GetNumFlags to determine the number of flags available for the mailbox.

Returns undef on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.

More Information and Examples
top
GetNumFlags
# $index is an integer
# $n is an integer
my $n = $mailboxes->GetNumFlags($index);

Returns the number of flags associated with the mailbox at the zero-based index specified by $index.

Returns -1 if $index is outside the valid mailbox-index range. Use GetNthFlag to retrieve the individual flags.

More Information and Examples
top
HasFlag
# $index is an integer
# $flagName is a string
# $flag is true or false
my $flag = $mailboxes->HasFlag($index, $flagName);

Returns 1 if the mailbox at the zero-based index specified by $index contains the flag named by $flagName.

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.

Never dies: false is an answer, not a failure.

top
HasInferiors
# $index is an integer
# $flag is true or false
my $flag = $mailboxes->HasInferiors($index);

Returns 1 if the mailbox at the zero-based index specified by $index either has child mailboxes or permits child mailboxes to be created beneath it.

Important distinction: \HasNoChildren means that no child mailboxes currently exist. It does not mean that children cannot be created. The IMAP \Noinferiors attribute means that child mailboxes cannot be created.

Never dies: false is an answer, not a failure.

More Information and Examples
top
IsMarked
# $index is an integer
# $flag is true or false
my $flag = $mailboxes->IsMarked($index);

Returns 1 if the mailbox at the zero-based index specified by $index has the IMAP \Marked attribute.

\Marked is 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.

Never dies: false is an answer, not a failure.

More Information and Examples
top
IsSelectable
# $index is an integer
# $flag is true or false
my $flag = $mailboxes->IsSelectable($index);

Returns 1 if the mailbox at the zero-based index specified by $index can be selected or examined for message access.

A mailbox having the IMAP \Noselect attribute is not selectable, even though it may appear in the mailbox hierarchy and may contain selectable child mailboxes.

Never dies: false is an answer, not a failure.

More Information and Examples
top