Sample code for 30+ languages & platforms
Tcl

Access Attached Message (Embedded Email)

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

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set email [new_CkEmail]

# Load an email from a .eml
set success [CkEmail_LoadEml $email "embeddedEmail.eml"]
if {$success == 0} then {
    puts [CkEmail_lastErrorText $email]
    delete_CkEmail $email
    exit
}

# Display how many attached emails are embedded within
# this one:
set numAttached [CkEmail_get_NumAttachedMessages $email]
puts "numAttached = $numAttached"

# Get the 1st attached message.
set email2 [new_CkEmail]

set success [CkEmail_GetAttachedEmail $email 0 $email2]
if {$success == 1} then {

    # Display the subject, From, and a header field...
    puts [CkEmail_subject $email2]
    puts [CkEmail_from $email2]
    puts [CkEmail_getHeaderField $email2 X-SOMETHING]
}


delete_CkEmail $email
delete_CkEmail $email2