Sample code for 30+ languages & platforms
Lianja

Download POP3 Email using UIDLs

Demonstrates how to download POP3 email by first getting the complete set of UIDLs and then downloading email by calling FetchByUIDL for each UIDL.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

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

// The mailman object is used for receiving (POP3) 
// and sending (SMTP) email.
loMailman = createobject("CkMailMan")

// Set the POP3 server's hostname
loMailman.MailHost = "pop.example.com"

// Set the POP3 login/password.
loMailman.PopUsername = "myLogin"
loMailman.PopPassword = "myPassword"

loStUidls = createobject("CkStringTable")
llSuccess = loMailman.FetchUidls(loStUidls)
if (llSuccess = .F.) then
    ? loMailman.LastErrorText
    release loMailman
    release loStUidls
    return
endif

loEmail = createobject("CkEmail")

lnCount = loStUidls.Count
i = 0
do while i < lnCount
    // Download the full email.
    llSuccess = loMailman.FetchByUidl(loStUidls.StringAt(i),.F.,0,loEmail)
    if (llSuccess = .F.) then
        ? loMailman.LastErrorText
        release loMailman
        release loStUidls
        release loEmail
        return
    endif

    ? str(i)
    ? "From: " + loEmail.From
    ? "Subject: " + loEmail.Subject

    i = i + 1
enddo

loMailman.Pop3EndSession()


release loMailman
release loStUidls
release loEmail