< Public Function GetHeader (Message As String, Header As String) As String (?)
Comments'------------------------------------------------------------------ 'Extract one value from an email header '------------------------------------------------------------------
Public Function GetHeader (Message As String, Header As String) As String
Dim i As Integer
Dim j As Integer
'Case-insensitive matching
Header = LCase(Header)
'Look the the place containing the start of this header
i = InStr(LCase(Message), vbCrLf & Header & ":")
'Exit if not found. (Header does not exist)
If i < 1 Then Exit Function
'Record the start of the data
i = i + Len(Header) + 1
'Look for the end of the line
j = InStr(i + 2, Message, vbCrLf)
'If end-of line not found
If j < 1 Then
'Get everything from the start of data to the end
GetHeader = Trim(TrimFrom(Message, i + 1, 0))
Else
'Get everything from the start of data to the newline
GetHeader = Trim(Mid(Message, i + 2, j - i - 2))
End If
End Function