Sample code for 30+ languages & platforms
JavaScript

POP3 Fetch Mime Source of Email by UIDL

Demonstrates how to fetch the MIME source of a single email by UIDL.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var mailman = new CkMailMan();

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

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

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

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

// Download each email as MIME.
var bdMime = new CkBinData();

var count = stUidls.Count;
var i = 0;
while (i < count) {
    success = mailman.FetchMimeBd(stUidls.StringAt(i),bdMime);
    if (success == false) {
        console.log(mailman.LastErrorText);
        return;
    }

    // Do whatever is needed with the MIME contained in bdMime.

    i = i+1;
}