Delphi DLL
Delphi DLL
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 Delphi DLL Downloads
var
email: HCkEmail;
n: Integer;
i: Integer;
begin
// 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.
email := CkEmail_Create();
CkEmail_putSubject(email,'Enumerate header values');
CkEmail_putFrom(email,'alice@example.com');
CkEmail_AddTo(email,'Bob','bob@example.com');
n := CkEmail_getNumHeaderFields(email);
for i := 0 to n - 1 do
begin
Memo1.Lines.Add(CkEmail__getHeaderFieldName(email,i) + ' = ' + CkEmail__getHeaderFieldValue(email,i));
end;
CkEmail_Dispose(email);