Sample code for 30+ languages & platforms
DataFlex

Iterate Email Headers

Demonstrates how to iterate over the email header fields.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoEmail
    Integer n
    Integer i
    String sName
    String sValue
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End

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

    Get ComLoadEml Of hoEmail "testReceivedHdrs.eml" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // How many header fields?

    Get ComNumHeaderFields Of hoEmail To n
    If (n > 0) Begin

        // Display the name and value of each header:

        For i From 0 To (n - 1)
            Get ComGetHeaderFieldName Of hoEmail i To sName
            Get ComGetHeaderFieldValue Of hoEmail i To sValue
            Showln i
            Showln sName
            Showln sValue

        Loop

    End



End_Procedure