PowerBuilder
PowerBuilder
Enumerate MIME Header Field Names
See more MIME Examples
Demonstrates the Chilkat Mime.GetHeaderFieldName method, which returns the name of the header-field occurrence at a zero-based index. The only argument is the index; use NumHeaderFields for the count. Original order and casing are preserved.
Note: The file path is relative to the application's current working directory. Absolute paths may also be used. Supply the path to your own file.
Background: When you need to walk all the headers — to display them, copy them, or handle duplicates that
GetHeaderField would hide — index-based access is the way. NumHeaderFields bounds the loop, and this returns each field's name in its original order and casing, which matters when the exact header sequence is significant.Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Mime
long n
long i
string ls_FieldName
li_Success = 0
loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
destroy loo_Mime
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Mime.LoadMimeFile("qa_data/message.eml")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// Iterate the header fields by index. NumHeaderFields gives the count; GetHeaderFieldName and
// GetHeaderFieldValue return the name and value at each zero-based index. Original order and
// casing are preserved.
n = loo_Mime.NumHeaderFields
Write-Debug "Header fields: " + string(n)
for i = 0 to n - 1
ls_FieldName = loo_Mime.GetHeaderFieldName(i)
if loo_Mime.LastMethodSuccess = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
Write-Debug ls_FieldName
next
destroy loo_Mime