Unicode C
Unicode C
Create an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.CreateMailbox method, which creates a mailbox on the IMAP server. When creating nested mailboxes, use the server's hierarchy delimiter reported in the SeparatorChar property. This example creates a mailbox named Archive2026.
Background: IMAP folders form a hierarchy, and the character that separates levels varies by server — commonly
/ or .. To create a sub-folder you build the path with that delimiter (for example Archive/2026), which is why you should read SeparatorChar rather than assume one. Creating mailboxes lets an application organize mail into folders programmatically, such as filing messages by year or project.Chilkat Unicode C Downloads
#include <C_CkImapW.h>
void ChilkatSample(void)
{
BOOL success;
HCkImapW imap;
success = FALSE;
// Demonstrates the Imap.CreateMailbox method, which creates a mailbox on the IMAP server.
// Use the server's hierarchy delimiter (the SeparatorChar property) when creating nested
// mailboxes.
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;
}
// Create a new mailbox (folder) on the server.
success = CkImapW_CreateMailbox(imap,L"Archive2026");
if (success == FALSE) {
wprintf(L"%s\n",CkImapW_lastErrorText(imap));
CkImapW_Dispose(imap);
return;
}
wprintf(L"Mailbox created.\n");
success = CkImapW_Disconnect(imap);
if (success == FALSE) {
wprintf(L"%s\n",CkImapW_lastErrorText(imap));
CkImapW_Dispose(imap);
return;
}
CkImapW_Dispose(imap);
}