Sample code for 30+ languages & platforms
VB.NET

Access Attached Message (Embedded Email)

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

Chilkat VB.NET Downloads

VB.NET
Dim success As Boolean = False

Dim email As New Chilkat.Email

' Load an email from a .eml
success = email.LoadEml("embeddedEmail.eml")
If (success = False) Then
    Debug.WriteLine(email.LastErrorText)
    Exit Sub
End If


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

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

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