B4X
B4X
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 B4X Downloads
Dim success As Boolean = False
Dim mime As ChilkatMime
mime.Initialize
success = mime.LoadMimeFile("qa_data/message.eml")
If success = False Then
Log(mime.LastErrorText)
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.
Dim n As Int = mime.NumHeaderFields
Log("Header fields: " & n)
Dim i As Int
For i = 0 To n - 1
Dim fieldName As String = mime.GetHeaderFieldName(i)
If mime.LastMethodSuccess = False Then
Log(mime.LastErrorText)
Return
End If
Log(fieldName)
Next