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

B4X
Dim success As Boolean = False

Dim email As ChilkatEmail
email.Initialize

'  Load an email from a .eml
success = email.LoadEml("embeddedEmail.eml")
If success = False Then
    Log(email.LastErrorText)
    Return
End If


'  Display how many attached emails are embedded within
'  this one:
Dim numAttached As Int = email.NumAttachedMessages
Log("numAttached = " & numAttached)

'  Get the 1st attached message.
Dim email2 As ChilkatEmail
email2.Initialize
success = email.GetAttachedEmail(0, email2)
If success = True Then

    '  Display the subject, From, and a header field...
    Log(email2.Subject)
    Log(email2.From)
    Log(email2.GetHeaderField("X-SOMETHING"))
End If