Sample code for 30+ languages & platforms
Go

Access Attached Message (Embedded Email)

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

Chilkat Go Downloads

Go
    success := false

    email := chilkat.NewEmail()

    //  Load an email from a .eml
    success = email.LoadEml("embeddedEmail.eml")
    if success == false {
        fmt.Println(email.LastErrorText())
        email.DisposeEmail()
        return
    }

    //  Display how many attached emails are embedded within
    //  this one:
    numAttached := email.NumAttachedMessages()
    fmt.Println("numAttached = ", numAttached)

    //  Get the 1st attached message.
    email2 := chilkat.NewEmail()
    success = email.GetAttachedEmail(0,email2)
    if success == true {

        //  Display the subject, From, and a header field...
        fmt.Println(email2.Subject())
        fmt.Println(email2.From())
        fmt.Println(*email2.GetHeaderField("X-SOMETHING"))
    }


    email.DisposeEmail()
    email2.DisposeEmail()