Internet Direct (Indy)
Home
PreviousUpNext
TIdIMAP4.SelectMailBox Method

Selects a mailbox on the IMAP4 server as the current mailbox for message access.

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

Boolean - True on success.

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 an 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 IMAP4 SELECT command for the specified mailbox name. On successful completion of the command, SelectMailBox parses the multi-line response and loads the values into the MailBox specified in AMBName. 

SelectMailBox sets ConnectionState to the value csSelected. If the response code from SendCmd contains a value other than wsOk, the value in ConnectionState is set csAuthenticated. 

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

Please note that IMAP servers are required to have an "Inbox" folder to allow them to receive email for a given user. This may or may not be case-sensitive. Your implementation may require you to create an Inbox folder if it does not already exist. 

Also, caution is advised when selecting the characters for mailbox names. Different IMAP servers may allow, and interpret differently, various characters, which is allowed within the IMAP specification. Characters such as ~ / and . may have special meaning in the IMAP servers context, and may produce unexpected results. In practice, some IMAP servers may be case-sensitive and others not. It is recommended that you only use the characters A-Z and 0-9 and that you program to allow for case sensitivity or insensitivity, as applicable. Note that, in general, IdIMAP4 adds double-quotes around mailbox names, which allows the use of spaces in mailbox names, but also note that a perticular IMAP server may not allow spaces (this functionality is necessary to allow IdIMAP4 deal with pre-existing mailboxes that include spaces). 

SelectMailBox sets the return value for the method to True when the IMAP4 server response contains the value IMAP_OK.

Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.