Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

Read a POP3 Mailbox

Read a POP3 mailbox and display the FROM and SUBJECT header fields of each email.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMailman
LOCAL oBundle
LOCAL nKeepOnServer
LOCAL nHeadersOnly
LOCAL nNumBodyLines
LOCAL i
LOCAL oEmail

nSuccess := 0

//  This example assumes 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.
oMailman := CreateObject("Chilkat.MailMan")

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

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

//  Copy the all email from the user's POP3 mailbox 
//  into a bundle object.  The email remains on the server.
oBundle := CreateObject("Chilkat.EmailBundle")
nKeepOnServer := 1
nHeadersOnly := 0
//  Irrelevent because we are NOT downloading headers-only
nNumBodyLines := 0
nSuccess := oMailman:FetchAll(nKeepOnServer, nHeadersOnly, nNumBodyLines, oBundle)
IF (nSuccess == 0)
    ? oMailman:LastErrorText
    oMailman:destroy()
    oBundle:destroy()
    RETURN
ENDIF

i := 0
oEmail := CreateObject("Chilkat.Email")
DO WHILE i < oBundle:MessageCount
    oBundle:EmailAt(i, oEmail)

    ? "From: " + oEmail:From
    ? "Subject: " + oEmail:Subject

    i := i + 1
ENDDO

nSuccess := oMailman:Pop3EndSession()

oMailman:destroy()
oBundle:destroy()
oEmail:destroy()