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

Read an attached email

See more Email Object Examples

Open forward-as-attachment.eml from the forwarding example. Read the cover note’s subject, then open each attached message and inspect its own headers and attachment count. This works even when the outer message has no ordinary files.

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 wrapper As New ChilkatEmail
success = wrapper.LoadEml("forward-as-attachment.eml")
If (success <> 1) Then
    Debug.Print wrapper.LastErrorText
    Exit Sub
End If

Debug.Print "Cover note: " & wrapper.Subject
If (wrapper.NumAttachedMessages = 0) Then
    Debug.Print "No attached messages."
    Exit Sub
End If

Dim nested As New ChilkatEmail
Dim i As Long
i = 0
Do While (i < wrapper.NumAttachedMessages)
    success = wrapper.GetAttachedEmail(i,nested)
    If (success <> 1) Then
        Debug.Print wrapper.LastErrorText
        Exit Sub
    End If

    Debug.Print "Original author: " & nested.From
    Debug.Print "Original subject: " & nested.Subject
    Debug.Print "Files on the original: " & nested.NumAttachments
    i = i + 1
Loop