Unicode C++
Unicode C++
Open an IMAP Mailbox Read-Only
See more IMAP Examples
Demonstrates the Chilkat Imap.ExamineMailbox method, which opens a mailbox as read-only. Use it instead of SelectMailbox when the application must not change message state, such as the \Seen flag. This example examines the Inbox.
Background: Reading a message can have a side effect: fetching its body normally sets the
\Seen flag, marking it as read. ExamineMailbox corresponds to IMAP's EXAMINE command, which opens the mailbox in a read-only mode where no such changes are made — ideal for scanning, indexing, or backup tools that must leave the user's mailbox exactly as they left it.Chilkat Unicode C++ Downloads
#include <CkImapW.h>
void ChilkatSample(void)
{
bool success = false;
// Demonstrates the Imap.ExamineMailbox method, which opens a mailbox as read-only. Use this
// instead of SelectMailbox when the application must not change message state (such as the
// \Seen flag).
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;
}
// Open the Inbox as read-only.
success = imap.ExamineMailbox(L"Inbox");
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
wprintf(L"Inbox opened read-only.\n");
success = imap.Disconnect();
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
}