Sample code for 30+ languages & platforms
C#

POP3 Fetch a Single Email by UIDL

Demonstrates how to fetch a single email by UIDL.

Chilkat C# Downloads

C#
bool success = false;

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

Chilkat.MailMan mailman = new Chilkat.MailMan();

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

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

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

Chilkat.StringTable stUidls = new Chilkat.StringTable();
success = mailman.FetchUidls(stUidls);
if (success == false) {
    Debug.WriteLine(mailman.LastErrorText);
    return;
}

Chilkat.Email email = new Chilkat.Email();

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

    Debug.WriteLine(Convert.ToString(i));
    Debug.WriteLine("From: " + email.From);
    Debug.WriteLine("Subject: " + email.Subject);

    i = i + 1;
}

mailman.Pop3EndSession();