B4X
B4X
Enumerate MIME Header Field Values
See more MIME Examples
Demonstrates the Chilkat Mime.GetHeaderFieldValue method, which returns the unfolded value of the header-field occurrence at a zero-based index. The only argument is the index. Continuation (folded) lines are combined into a single value.
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: Paired with
GetHeaderFieldName, this lets you list every header as name/value pairs, including duplicates. A useful detail is unfolding: long headers are wrapped across multiple physical lines in the raw message, and this recombines them into the single logical value the header actually represents, so you never have to reassemble continuation lines yourself.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 and print each name and unfolded value. Continuation lines
' (folded headers) are combined into a single value.
Dim n As Int = mime.NumHeaderFields
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
Dim fieldValue As String = mime.GetHeaderFieldValue(i)
If mime.LastMethodSuccess = False Then
Log(mime.LastErrorText)
Return
End If
Log(fieldName & ": " & fieldValue)
Next