Sample code for 30+ languages & platforms
Node.js

POP3 Fetch a Single Email by UIDL

Demonstrates how to fetch a single email by UIDL.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    var mailman = new chilkat.MailMan();

    mailman.MailHost = "pop.example.com";

    mailman.PopUsername = "myLogin";
    mailman.PopPassword = "myPassword";

    mailman.MailPort = 995;
    mailman.PopSsl = true;

    var stUidls = new chilkat.StringTable();
    success = mailman.FetchUidls(stUidls);
    if (success == false) {
        console.log(mailman.LastErrorText);
        return;
    }

    var email = new chilkat.Email();

    var count = stUidls.Count;
    var i = 0;
    while (i < count) {
        //  Download the full email.
        success = mailman.FetchByUidl(stUidls.StringAt(i),false,0,email);
        if (success == false) {
            console.log(mailman.LastErrorText);
            return;
        }

        console.log(i);
        console.log("From: " + email.From);
        console.log("Subject: " + email.Subject);

        i = i+1;
    }

    mailman.Pop3EndSession();

}

chilkatExample();