Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

Access Attached Message (Embedded Email)

How to access an email embedded within another email (i.e. an attached message).

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oEmail
LOCAL nNumAttached
LOCAL oEmail2

nSuccess := 0

oEmail := CreateObject("Chilkat.Email")

//  Load an email from a .eml
nSuccess := oEmail:LoadEml("embeddedEmail.eml")
IF (nSuccess == 0)
    ? oEmail:LastErrorText
    oEmail:destroy()
    RETURN
ENDIF

//  Display how many attached emails are embedded within
//  this one:
nNumAttached := oEmail:NumAttachedMessages
? "numAttached = " + Str(nNumAttached)

//  Get the 1st attached message.
oEmail2 := CreateObject("Chilkat.Email")
nSuccess := oEmail:GetAttachedEmail(0, oEmail2)
IF (nSuccess == 1)

    //  Display the subject, From, and a header field...
    ? oEmail2:Subject
    ? oEmail2:From
    ? oEmail2:GetHeaderField("X-SOMETHING")
ENDIF

oEmail:destroy()
oEmail2:destroy()