Internet Direct (Indy) Version 9.0.1 Beta
TIdIMAP4.SelectMailBox
Selects a mailbox on the IMAP4 server as the current mailbox for message access.

function SelectMailBox(const AMBName: String): Boolean; overload;
Parameters
const AMBName: String
Mailbox name to be activated.

Returns
Boolean - True on success.

Description
SelectMailBox is a Boolean function that selects the mailbox specified in AMBName as the current mailbox for message access on the IMAP4 server. Only one mailbox can be selected at a time in a IMAP4 connection. Simultaneous access to multiple mailboxes requires multiple connections. SelectMailBox automatically deselects any currently selected mailbox before attempting the new selection. Consequently, if a mailbox is selected and a SELECT command that fails is attempted, no mailbox is selected.

SelectMailBox requires that the value of ConnectionState contain either csAuthenticated or csSelected, or an EIdConnectionStateError exception will be raised.

SelectMailBox calls SendCmd using the IMAPO4 SELECT command for the specified mailbox name. On successful completion of the command, SelectMailBox calls ParseSelectResultDetails to load the values in CmdResultDetails into MailBox. SelectMailBox also sets ConnectionState to the value csSelected.

SelectMailBox also calls either RetrieveAllHeaders or RetrieveAllMsgs, based on the value of RetrieveOnSelect, to populate the message list in MailBox.

SelectMailBox sets the return value for the method to True when ResultNo contains the value wsOk.