Sample code for 30+ languages & platforms
Visual Basic 6.0 Requires Chilkat v11.0.0+

Read email headers and display the body as text

See more Email Object Examples

Read the sender, recipients, subject, date, and an optional custom header from an EML file. Display the plain-text body when available, or convert HTML to text. Handle messages that contain neither body format.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.

Dim email As New ChilkatEmail
success = email.LoadEml("with-attachments.eml")
If (success <> 1) Then
    Debug.Print email.LastErrorText
    Exit Sub
End If

Debug.Print "From: " & email.From
Debug.Print "Subject: " & email.Subject
Debug.Print "Date: " & email.EmailDateStr
Dim i As Long
i = 0
Do While (i < email.NumTo)
    Debug.Print "To: " & email.GetToName(i) & "  " & email.GetToAddr(i)
    i = i + 1
Loop
Dim referenceId As String
referenceId = email.GetHeaderField("X-Reference-ID")
If (email.LastMethodSuccess = 1) Then
    Debug.Print "Reference: " & referenceId
End If

If (email.HasPlainTextBody() = 1) Then
    Debug.Print email.GetPlainTextBody()
Else
    If (email.HasHtmlBody() = 1) Then
        Dim reader As New HtmlToText
        Debug.Print reader.ToText(email.GetHtmlBody())
    Else
        Debug.Print "No text or HTML body."
    End If

End If