Internet Direct (Indy) Version 9.0.1 Beta
TIdIMAP4.RenameMailBox
Renames a specified mailbox on the IMAP4 server.

function RenameMailBox(const AOldMBName: String; const ANewMBName: String): Boolean;
Parameters
const AOldMBName: String
Mailbox name to be changed .

const ANewMBName: String
New name for the mailbox.

Returns
Boolean - True on success.

Description
RenameMailBox is a Boolean function that renames the mailbox specified in AOldMBName to the value specified in ANewMBName on the IMAP4 server. RenameMailBox will receive a protocol error if AOldMBName does not exist, of when ANewMBName already exists.

Renaming the "INBOX" mailbox is permitted, and has special behavior. It moves all messages in INBOX to a new mailbox with the given name, leaving INBOX empty. If the server implementation supports inferior hierarchical names of INBOX, these are unaffected by a rename of INBOX.

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

RenameMailBox calls SendCmd using the IMAP4 RENAME command to alter the mailbox name. RenameMailBox sets the return value to True when ResultNo contains the value wsOk.