Sample code for 30+ languages & platforms
PowerBuilder

Get the Value of the Nth Header Field

See more Email Object Examples

Demonstrates the Chilkat Email.GetHeaderFieldValue method, which returns the value of the Nth header field. Indexing begins at 0, and the count comes from NumHeaderFields. This example walks every header field, printing each name together with its value.

Background: GetHeaderFieldValue is the value half of index-based header enumeration — GetHeaderFieldName gives the field name at the same index. Iterating both is the reliable way to dump or inspect a full header block, including any repeated fields, which a name-based lookup would collapse to a single occurrence.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Email
integer n
integer i

//  Demonstrates the GetHeaderFieldValue method, which returns the value of the Nth header
//  field.  Indexing begins at 0; the number of header fields is given by NumHeaderFields.

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 values"
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 loo_Email.GetHeaderFieldName(i) + " = " + loo_Email.GetHeaderFieldValue(i)
next


destroy loo_Email