Sample code for 30+ languages & platforms
Visual FoxPro

Iterate Email Headers

Demonstrates how to iterate over the email header fields.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loEmail
LOCAL n
LOCAL i
LOCAL lcName
LOCAL lcValue

lnSuccess = 0

loEmail = CreateObject('Chilkat.Email')

* First, load an email from a file. 
* Note: an email object may be loaded from a file, or
* downloaded directly from a POP3 or IMAP server...

lnSuccess = loEmail.LoadEml("testReceivedHdrs.eml")
IF (lnSuccess <> 1) THEN
    ? loEmail.LastErrorText
    RELEASE loEmail
    CANCEL
ENDIF

* How many header fields?

n = loEmail.NumHeaderFields
IF (n > 0) THEN

    * Display the name and value of each header:

    FOR i = 0 TO n - 1
        lcName = loEmail.GetHeaderFieldName(i)
        lcValue = loEmail.GetHeaderFieldValue(i)
        ? STR(i)
        ? lcName
        ? lcValue

    NEXT

ENDIF

RELEASE loEmail