(C++) POP3 Fetch a Single Email by UIDL
Demonstrates how to fetch a single email by UIDL.
#include <CkMailMan.h>
#include <CkStringArray.h>
#include <CkEmail.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkMailMan mailman;
mailman.put_MailHost("pop.example.com");
mailman.put_PopUsername("myLogin");
mailman.put_PopPassword("myPassword");
mailman.put_MailPort(995);
mailman.put_PopSsl(true);
CkStringArray *sa = mailman.GetUidls();
if (mailman.get_LastMethodSuccess() == false) {
std::cout << mailman.lastErrorText() << "\r\n";
return;
}
// Download each email by UIDL.
const char *uidl = 0;
int i = 0;
int numUidls = sa->get_Count();
while (i < numUidls) {
uidl = sa->getString(i);
std::cout << uidl << "\r\n";
CkEmail *email = mailman.FetchEmail(uidl);
if (mailman.get_LastMethodSuccess() == false) {
std::cout << mailman.lastErrorText() << "\r\n";
return;
}
std::cout << email->subject() << "\r\n";
std::cout << "" << "\r\n";
delete email;
i = i + 1;
}
delete sa;
}
|