Swift Requires Chilkat v11.0.0+
Swift
Pass an Email object to the MIME API
See more Email Object Examples
Serialize an Email into a fresh BinData buffer and load those bytes into Mime to inspect the tree. Keep the original file separately when byte-for-byte preservation matters, such as for DKIM verification.
Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
// Assumes Chilkat is unlocked. See Global Unlock Sample.
let email = CkoEmail()!
success = email.loadEml(mimePath: "message.eml")
if success != true {
print("\(email.lastErrorText!)")
return
}
let mimeBytes = CkoBinData()!
success = email.getMimeBd(bindat: mimeBytes)
if success != true {
print("\(email.lastErrorText!)")
return
}
let mime = CkoMime()!
success = mime.loadBd(bindat: mimeBytes)
if success != true {
print("\(mime.lastErrorText!)")
return
}
print("\(mime.getStructure(fmt: "text")!)")
}