Xbase++ Requires Chilkat v11.0.0+
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oWrapper
LOCAL oNested
LOCAL i
nSuccess := 0
// Assumes Chilkat is unlocked. See Global Unlock Sample.
oWrapper := CreateObject("Chilkat.Email")
nSuccess := oWrapper:LoadEml("forward-as-attachment.eml")
IF (nSuccess != 1)
? oWrapper:LastErrorText
oWrapper:destroy()
RETURN
ENDIF
? "Cover note: " + oWrapper:Subject
IF (oWrapper:NumAttachedMessages == 0)
? "No attached messages."
oWrapper:destroy()
RETURN
ENDIF
oNested := CreateObject("Chilkat.Email")
i := 0
DO WHILE (i < oWrapper:NumAttachedMessages)
nSuccess := oWrapper:GetAttachedEmail(i, oNested)
IF (nSuccess != 1)
? oWrapper:LastErrorText
oWrapper:destroy()
oNested:destroy()
RETURN
ENDIF
? "Original author: " + oNested:From
? "Original subject: " + oNested:Subject
? "Files on the original: " + Str(oNested:NumAttachments)
i := i + 1
ENDDO
oWrapper:destroy()
oNested:destroy()