Sample code for 30+ languages & platforms
Lianja

Iterate Email Headers

Demonstrates how to iterate over the email header fields.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loEmail = createobject("CkEmail")

// 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...

llSuccess = loEmail.LoadEml("testReceivedHdrs.eml")
if (llSuccess <> .T.) then
    ? loEmail.LastErrorText
    release loEmail
    return
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