C
C
Unsubscribe from an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.Unsubscribe method, which removes the subscription to a mailbox. The mailbox itself and its messages are not deleted. This example unsubscribes from a mailbox.
Background: Unsubscribing simply drops a mailbox from the account's subscription list, so clients that show only subscribed folders will stop displaying it — the folder and everything in it remain on the server untouched. This is the counterpart to
Subscribe, and is how you declutter a mailbox listing without deleting anything (deleting a folder is DeleteMailbox).Chilkat C Downloads
#include <C_CkImap.h>
void ChilkatSample(void)
{
BOOL success;
HCkImap imap;
success = FALSE;
// Demonstrates the Imap.Unsubscribe method, which removes the subscription to a mailbox.
// The mailbox itself and its messages are not deleted.
imap = CkImap_Create();
CkImap_putSsl(imap,TRUE);
CkImap_putPort(imap,993);
success = CkImap_Connect(imap,"imap.example.com");
if (success == FALSE) {
printf("%s\n",CkImap_lastErrorText(imap));
CkImap_Dispose(imap);
return;
}
success = CkImap_Login(imap,"user@example.com","myPassword");
if (success == FALSE) {
printf("%s\n",CkImap_lastErrorText(imap));
CkImap_Dispose(imap);
return;
}
// Remove the subscription to a mailbox (the mailbox is not deleted).
success = CkImap_Unsubscribe(imap,"Archive2026");
if (success == FALSE) {
printf("%s\n",CkImap_lastErrorText(imap));
CkImap_Dispose(imap);
return;
}
printf("Unsubscribed from the mailbox.\n");
success = CkImap_Disconnect(imap);
if (success == FALSE) {
printf("%s\n",CkImap_lastErrorText(imap));
CkImap_Dispose(imap);
return;
}
CkImap_Dispose(imap);
}