Sample code for 30+ languages & platforms
Xojo Plugin 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 Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

Dim wrapper As New Chilkat.Email
success = wrapper.LoadEml("forward-as-attachment.eml")
If (success <> True) Then
    System.DebugLog(wrapper.LastErrorText)
    Return
End If

System.DebugLog("Cover note: " + wrapper.Subject)
If (wrapper.NumAttachedMessages = 0) Then
    System.DebugLog("No attached messages.")
    Return
End If

Dim nested As New Chilkat.Email
Dim i As Int32
i = 0
While (i < wrapper.NumAttachedMessages)
    success = wrapper.GetAttachedEmail(i,nested)
    If (success <> True) Then
        System.DebugLog(wrapper.LastErrorText)
        Return
    End If

    System.DebugLog("Original author: " + nested.From)
    System.DebugLog("Original subject: " + nested.Subject)
    System.DebugLog("Files on the original: " + Str(nested.NumAttachments))
    i = i + 1
Wend