Sample code for 30+ languages & platforms
CkPython

Access Attached Message (Embedded Email)

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

Chilkat CkPython Downloads

CkPython
import sys
import chilkat

success = False

email = chilkat.CkEmail()

#  Load an email from a .eml
success = email.LoadEml("embeddedEmail.eml")
if (success == False):
    print(email.lastErrorText())
    sys.exit()

#  Display how many attached emails are embedded within
#  this one:
numAttached = email.get_NumAttachedMessages()
print("numAttached = " + str(numAttached))

#  Get the 1st attached message.
email2 = chilkat.CkEmail()
success = email.GetAttachedEmail(0,email2)
if (success == True):

    #  Display the subject, From, and a header field...
    print(email2.subject())
    print(email2.ck_from())
    print(email2.getHeaderField("X-SOMETHING"))