CImapClient::RenameMailbox Method  
 
INT RenameMailbox(
  LPCTSTR lpszOldMailbox,  
  LPCTSTR lpszNewMailbox  
);

The RenameMailbox method renames an existing mailbox.

Parameters

lpszOldMailbox
A pointer to a string which specifies the mailbox to be renamed.
lpszNewMailbox
A pointer to a string which specifies the new mailbox name.

Return Value

If the method succeeds, it returns zero. If an error occurs, the method returns IMAP_ERROR. To get extended error information, call GetLastError.

Remarks

The RenameMailbox method renames an existing mailbox on the server. The new mailbox name cannot exist on the server, or the method will fail.

If the existing mailbox name contains inferior hierarchical names (mailboxes under the specified mailbox) then those mailboxes will also be renamed. For example, if the mailbox "Mail/Pictures" contains two mailboxes, "Personal" and "Work" and it is renamed to "Mail/Images" then the two mailboxes under it would be automatically renamed to "Mail/Images/Personal" and "Mail/Images/Work".

If the mailbox being renamed is the currently selected mailbox, the current mailbox will be unselected and any messages marked for deletion will be expunged. The new mailbox name will then automatically be re-selected. To prevent deleted messages from being removed from the mailbox prior to being renamed, use the UnselectMailbox method to unselect the current mailbox before calling RenameMailbox. Note that if the rename operation fails, the client may be left in an unselected state.

It is permitted to rename the special mailbox INBOX. In this case, the messages will be moved from the INBOX mailbox to the new mailbox. If the INBOX mailbox is currently selected, the new mailbox will not automatically be selected. INBOX will remain the selected mailbox.

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csmapv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

CreateMailbox, DeleteMailbox, GetFirstMailbox, GetNextMailbox