PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
oleobject loo_Email
integer n
integer i
// 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.
loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
destroy loo_Email
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Email.Subject = "Enumerate header names"
loo_Email.From = "alice@example.com"
loo_Email.AddTo("Bob","bob@example.com")
n = loo_Email.NumHeaderFields
for i = 0 to n - 1
Write-Debug "Header " + string(i) + " name: " + loo_Email.GetHeaderFieldName(i)
next
destroy loo_Email