Sample code for 30+ languages & platforms
Unicode C++

Process Large POP3 Mailbox

Demonstrates how to read email from a mailbox that may contain a large number of emails.

Chilkat Unicode C++ Downloads

Unicode C++
#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);

    //  Get the list of UIDLs for all emails in the mailbox.
    CkStringTableW stUidls;
    success = mailman.FetchUidls(stUidls);
    if (success == false) {
        wprintf(L"%s\n",mailman.lastErrorText());
        return;
    }

    //  Download each email by UIDL.
    CkEmailW email;

    int count = stUidls.get_Count();
    int i = 0;
    while (i < count) {
        //  Download the full email.
        const wchar_t *uidl = stUidls.stringAt(i);
        success = mailman.FetchByUidl(uidl,false,0,email);
        if (success == false) {
            wprintf(L"%s\n",mailman.lastErrorText());
            return;
        }

        wprintf(L"%d\n",i);
        wprintf(L"UIDL: %s\n",uidl);
        wprintf(L"From: %s\n",email.ck_from());
        wprintf(L"Subject: %s\n",email.subject());

        i = i + 1;
    }

    mailman.Pop3EndSession();
    }