Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component

Index of Chilkat Blog Posts

July 13, 2007

Parsing Received Email Header Fields in VB6

Each mail server that relays a message while an email is in transit will add a "Recieved" header field. When an email is delivered to its final destination, it may contain multiple "Received" header fields. This VB6 example demonstrates how to iterate over the Received headers and parse the dates.

It uses the CkString ActiveX, which is a freeware string utility ActiveX downloadable at

Dim email As New ChilkatEmail2
'  First, load an email.  This example loads an email from
'  a file.
Dim success As Long
success = email.LoadEml("testReceivedHdrs.eml")
If (success <> 1) Then
    MsgBox email.LastErrorText
    Exit Sub
End If
Dim n As Long
n = email.NumHeaderFields()
'  List the Received header fields:
Dim i As Long
Dim name As String
Dim value As String
Dim strUtil As New CkString
Dim d As Date
For i = 0 To n - 1
    name = email.GetHeaderFieldName(i)
    If (StrComp("received", name, vbTextCompare) = 0) Then
        value = email.GetHeaderFieldValue(i)
        idx = InStrRev(value, ";")
        If (idx >= 0) Then
            idx = idx + 1
            value = Mid$(value, idx)
            strUtil.Str = value
            d = strUtil.ParseDateRfc822
            Text1.Text = Text1.Text & d & vbCrLf
        End If
    End If

Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.