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

POP3 Fetch Mime Source of Email by UIDL

Demonstrates how to fetch the MIME source of a single email by UIDL.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMailman
LOCAL oStUidls
LOCAL oBdMime
LOCAL nCount
LOCAL i

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

oStUidls := CreateObject("Chilkat.StringTable")
nSuccess := oMailman:FetchUidls(oStUidls)
IF (nSuccess == 0)
    ? oMailman:LastErrorText
    oMailman:destroy()
    oStUidls:destroy()
    RETURN
ENDIF

//  Download each email as MIME.
oBdMime := CreateObject("Chilkat.BinData")

nCount := oStUidls:Count
i := 0
DO WHILE i < nCount
    nSuccess := oMailman:FetchMimeBd(oStUidls:StringAt(i), oBdMime)
    IF (nSuccess == 0)
        ? oMailman:LastErrorText
        oMailman:destroy()
        oStUidls:destroy()
        oBdMime:destroy()
        RETURN
    ENDIF

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

    i := i + 1
ENDDO

oMailman:destroy()
oStUidls:destroy()
oBdMime:destroy()