Unicode C
Unicode C
Explicitly Begin a POP3 Session
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3BeginSession method, which explicitly begins a POP3 session by connecting to the POP3 server and authenticating using the current POP3 property settings. Calling it is optional. This example begins a session, performs a mailbox operation, and ends the session.
Background:
Pop3BeginSession combines connecting and authenticating into one call. Chilkat does this automatically when a mailbox operation needs it, so the value of calling it explicitly is control: you open one session, perform several operations against it, and close it with Pop3EndSession — avoiding repeated connect/authenticate round trips and keeping deletion marks within a single, well-defined session.Chilkat Unicode C Downloads
#include <C_CkMailManW.h>
void ChilkatSample(void)
{
BOOL success;
HCkMailManW mailman;
success = FALSE;
// Demonstrates the MailMan.Pop3BeginSession method, which explicitly begins a POP3 session
// by connecting to the POP3 server and authenticating using the current POP3 property
// settings.
mailman = CkMailManW_Create();
// Configure the POP3 server connection.
CkMailManW_putMailHost(mailman,L"pop.example.com");
CkMailManW_putMailPort(mailman,995);
CkMailManW_putPopSsl(mailman,TRUE);
CkMailManW_putPopUsername(mailman,L"user@example.com");
CkMailManW_putPopPassword(mailman,L"myPassword");
// Explicitly begin the POP3 session (connect + authenticate).
success = CkMailManW_Pop3BeginSession(mailman);
if (success == FALSE) {
wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
CkMailManW_Dispose(mailman);
return;
}
// Perform one or more mailbox operations within this single session.
wprintf(L"Mailbox count: %d\n",CkMailManW_GetMailboxCount(mailman));
// End the session when finished.
success = CkMailManW_Pop3EndSession(mailman);
if (success == FALSE) {
wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
CkMailManW_Dispose(mailman);
return;
}
wprintf(L"POP3 session completed.\n");
CkMailManW_Dispose(mailman);
}