(Unicode C++) POP3 Fetch a Single Email by UIDL
Demonstrates how to fetch a single email by UIDL. Note: This example requires Chilkat v11.0.0 or greater.
#include <CkMailManW.h>
#include <CkStringTableW.h>
#include <CkEmailW.h>
void ChilkatSample(void)
{
bool success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkMailManW mailman;
mailman.put_MailHost(L"pop.example.com");
mailman.put_PopUsername(L"myLogin");
mailman.put_PopPassword(L"myPassword");
mailman.put_MailPort(995);
mailman.put_PopSsl(true);
CkStringTableW stUidls;
success = mailman.FetchUidls(stUidls);
if (success == false) {
wprintf(L"%s\n",mailman.lastErrorText());
return;
}
CkEmailW email;
int count = stUidls.get_Count();
int i = 0;
while (i < count) {
// Download the full email.
success = mailman.FetchByUidl(stUidls.stringAt(i),false,0,email);
if (success == false) {
wprintf(L"%s\n",mailman.lastErrorText());
return;
}
wprintf(L"%d\n",i);
wprintf(L"From: %s\n",email.ck_from());
wprintf(L"Subject: %s\n",email.subject());
i = i + 1;
}
mailman.Pop3EndSession();
}
|