Xbase++ Requires Chilkat v11.0.0+
Xbase++
Process Large POP3 Mailbox
Demonstrates how to read email from a mailbox that may contain a large number of emails.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oMailman
LOCAL oStUidls
LOCAL oEmail
LOCAL nCount
LOCAL i
LOCAL cUidl
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oMailman := CreateObject("Chilkat.MailMan")
oMailman:MailHost := "pop.example.com"
oMailman:PopUsername := "myLogin"
oMailman:PopPassword := "myPassword"
oMailman:MailPort := 995
oMailman:PopSsl := 1
// Get the list of UIDLs for all emails in the mailbox.
oStUidls := CreateObject("Chilkat.StringTable")
nSuccess := oMailman:FetchUidls(oStUidls)
IF (nSuccess == 0)
? oMailman:LastErrorText
oMailman:destroy()
oStUidls:destroy()
RETURN
ENDIF
// Download each email by UIDL.
oEmail := CreateObject("Chilkat.Email")
nCount := oStUidls:Count
i := 0
DO WHILE i < nCount
// Download the full email.
cUidl := oStUidls:StringAt(i)
nSuccess := oMailman:FetchByUidl(cUidl, 0, 0, oEmail)
IF (nSuccess == 0)
? oMailman:LastErrorText
oMailman:destroy()
oStUidls:destroy()
oEmail:destroy()
RETURN
ENDIF
? Str(i)
? "UIDL: " + cUidl
? "From: " + oEmail:From
? "Subject: " + oEmail:Subject
i := i + 1
ENDDO
oMailman:Pop3EndSession()
oMailman:destroy()
oStUidls:destroy()
oEmail:destroy()