(Swift) Access Attached Message (Embedded Email)
How to access an email embedded within another email (i.e. an attached message). Note: This example requires Chilkat v11.0.0 or greater.
func chilkatTest() {
var success: Bool = false
let email = CkoEmail()!
// Load an email from a .eml
success = email.loadEml("embeddedEmail.eml")
if success == false {
print("\(email.lastErrorText!)")
return
}
// Display how many attached emails are embedded within
// this one:
var numAttached: Int = email.numAttachedMessages.intValue
print("numAttached = \(numAttached)")
// Get the 1st attached message.
let email2 = CkoEmail()!
success = email.getAttached(0, email: email2)
if success == true {
// Display the subject, From, and a header field...
print("\(email2.subject!)")
print("\(email2.from!)")
print("\(email2.getHeaderField("X-SOMETHING")!)")
}
}
|