Unicode C++
Unicode C++
Rename an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.RenameMailbox method, which renames a mailbox from the first name to the second. Changing the hierarchy components in the new name can also move a mailbox within the server's folder tree. This example renames OldName to NewName.
Background: Because a mailbox's full name encodes its place in the folder hierarchy, renaming is also how you move a folder: renaming
Inbox/Draft to Archive/Draft relocates it under a different parent. The messages inside move along with the folder. This makes RenameMailbox the tool for both relabeling and reorganizing an account's folder structure.Chilkat Unicode C++ Downloads
#include <CkImapW.h>
void ChilkatSample(void)
{
bool success = false;
// Demonstrates the Imap.RenameMailbox method, which renames a mailbox. Changing hierarchy
// components can also move a mailbox within the server's folder tree.
CkImapW imap;
imap.put_Ssl(true);
imap.put_Port(993);
success = imap.Connect(L"imap.example.com");
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
success = imap.Login(L"user@example.com",L"myPassword");
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
// Rename a mailbox from "OldName" to "NewName".
success = imap.RenameMailbox(L"OldName",L"NewName");
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
wprintf(L"Mailbox renamed.\n");
success = imap.Disconnect();
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
}