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

Creates a new mailbox on the remote IMAP4 server for the current account.

function CreateMailBox(
    const AMBName: String
): Boolean;
Mailbox name to create on the IMAP4 server. 

Boolean - True on success, False on error.

CreateMailBox is a Boolean function used to create a mailbox with the name indicated in AMBName on the remote IMAP4 server. AMBName must represent a valid mailbox name that does not already exist on the IMAP4 server. 

CreateMailBox requires that ConnectionState contain the value csAuthenticated or csSelected, indicating that the connection was successfully authenticated using the values in the Username and Password properties. When ConnectionState contains any other value, an EIdConnectionStateError exception is raised. 

CreateMailBox uses SendCmd to send the IMAP4 CREATE command using a UTF7-encoded copy of the value specified in AMBName. 

CreateMailBox returns True if the requested mailbox was successfully created on the remote IMAP4 server, or False when a protocol response indicates the operation was not successfully completed. The return value for the method is set to True if the server response is IMAP_OK. A value other than IMAP_OK generally indicates that the IMAP4 account does not have permissions required to create new mailboxes on the server. Use LastCmdResult to access the protocol response and determine the exact reason for the failure. 

Use DeleteMailbox, ExpungeMailbox, ExamineMailbox, or StatusMailbox to perform maintenance for a mailbox on the remote IMAP4 server.

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