DataFlex
DataFlex
Get the Name of the Nth Header Field
See more Email Object Examples
Demonstrates the Chilkat Email.GetHeaderFieldName method, which returns the name of the Nth header field. The NumHeaderFields property gives the count, and indexing is zero-based. This example enumerates the names of all header fields.
Background: Enumerating headers by index — rather than looking them up by name — lets you discover which fields a message actually contains and see repeated fields (like multiple
Received lines) in order. Pair GetHeaderFieldName with GetHeaderFieldValue at the same index to walk the entire header block as name/value pairs.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
Boolean iSuccess
Integer n
Integer i
String sTemp1
// Demonstrates the GetHeaderFieldName method, which returns the name of the Nth header
// field. The NumHeaderFields property gives the number of header fields; indexing is
// zero-based.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "Enumerate header names"
Set ComFrom Of hoEmail To "alice@example.com"
Get ComAddTo Of hoEmail "Bob" "bob@example.com" To iSuccess
Get ComNumHeaderFields Of hoEmail To n
For i From 0 To (n - 1)
Get ComGetHeaderFieldName Of hoEmail i To sTemp1
Showln "Header " i " name: " sTemp1
Loop
End_Procedure