Unicode C
Unicode C
Delete an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.DeleteMailbox method, which deletes a mailbox from the IMAP server. This deletes the mailbox itself, not merely the messages it contains. This example deletes a mailbox named OldFolder.
Background: Deleting a mailbox removes the folder and everything in it — an irreversible action, so applications typically confirm first. Server rules can add constraints: some refuse to delete a folder that still has child folders, or that is currently selected. This is the counterpart to
CreateMailbox; to remove individual messages rather than a whole folder, mark them deleted and Expunge.Chilkat Unicode C Downloads
#include <C_CkImapW.h>
void ChilkatSample(void)
{
BOOL success;
HCkImapW imap;
success = FALSE;
// Demonstrates the Imap.DeleteMailbox method, which deletes a mailbox from the IMAP server.
// This deletes the mailbox itself, not merely the messages it contains.
imap = CkImapW_Create();
CkImapW_putSsl(imap,TRUE);
CkImapW_putPort(imap,993);
success = CkImapW_Connect(imap,L"imap.example.com");
if (success == FALSE) {
wprintf(L"%s\n",CkImapW_lastErrorText(imap));
CkImapW_Dispose(imap);
return;
}
success = CkImapW_Login(imap,L"user@example.com",L"myPassword");
if (success == FALSE) {
wprintf(L"%s\n",CkImapW_lastErrorText(imap));
CkImapW_Dispose(imap);
return;
}
// Delete a mailbox (folder) from the server.
success = CkImapW_DeleteMailbox(imap,L"OldFolder");
if (success == FALSE) {
wprintf(L"%s\n",CkImapW_lastErrorText(imap));
CkImapW_Dispose(imap);
return;
}
wprintf(L"Mailbox deleted.\n");
success = CkImapW_Disconnect(imap);
if (success == FALSE) {
wprintf(L"%s\n",CkImapW_lastErrorText(imap));
CkImapW_Dispose(imap);
return;
}
CkImapW_Dispose(imap);
}