Topic Path: Symbol Reference > Classes > TIdIMAP4 Class > TIdIMAP4 Methods > SubscribeMailBox Method
TIdIMAP4.SubscribeMailBox Method

Adds a mailbox to the list of "active" or "subscribed" mailboxes.

function SubscribeMailBox(
    const AMBName: String
): Boolean;
Mailbox name to add to the active mailbox list. 

Boolean - True on success.

SubscribeMailBox is a Boolean function used to add the mailbox name specified in AMBName to the list of "active" or "subscribed" mailboxes on the IMAP4 server. SubscribeMailBox updates the values that are returned by the IMAP4 LSUB command. 

SubscribeMailBox requires that ConnectionState contain the value csAuthenticated or csSelected to perform the IMAP4 function. SubscribeMailBox can raise an EIdConnectionStateError exception with the message RSIMAP4ConnectionStateError if ConnectionState contains a value other than csAuthenticated or csSelected. 

SubscribeMailBox calls SendCmd using the IMAP4 SUBSCRIBE command and the value specified in AMBName as an argument. The IMAP4 server may validate the mailbox argument in AMBName to verify that it exists. SubscribeMailBox returns True when the server response contains the value IMAP_OK

Use UnsubscribeMailBox to remove a specified mailbox from the "active" or "subscibed" list. 

Please note that IMAP4 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 choosing the characters used 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).

Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.