Unicode C++
Unicode C++
Send a Raw IMAP Command
See more IMAP Examples
Demonstrates the Chilkat Imap.SendRawCommand method, which sends raw IMAP command text and returns the raw server response. Pass the command itself (such as NOOP) without an IMAP tag — Chilkat adds the tag automatically. This example sends a raw NOOP.
Background: Every IMAP command a client sends is prefixed with a short unique tag (like
a001) so the client can match the tagged completion response to the command it issued. SendRawCommand handles that tagging for you and returns the server's reply verbatim — an escape hatch for issuing a command Chilkat doesn't wrap directly, or a server-specific extension, without leaving the established authenticated session.Chilkat Unicode C++ Downloads
#include <CkImapW.h>
void ChilkatSample(void)
{
bool success = false;
// Demonstrates the Imap.SendRawCommand method, which sends raw IMAP command text and returns
// the raw server response. Pass the command itself (such as NOOP) without an IMAP tag --
// Chilkat adds the tag automatically.
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;
}
// Send a raw IMAP command and read the raw response.
const wchar_t *response = imap.sendRawCommand(L"NOOP");
if (imap.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
wprintf(L"%s\n",response);
success = imap.Disconnect();
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
}