Swift
Swift
Transition from MailMan.LoadXmlEmail to Email.SetFromXmlText
Provides instructions for replacing deprecated LoadXmlEmail method calls with Email.SetFromXmlText.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
let mailman = CkoMailMan()!
// ...
// ...
var xmlFilePath: String? = "c:/test/example.xml"
// ------------------------------------------------------------------------
// The LoadXmlEmail method is deprecated:
var emailObj: CkoEmail? = mailman.loadXmlEmail(folderPath: xmlFilePath)
if mailman.lastMethodSuccess == false {
print("\(mailman.lastErrorText!)")
return
}
// ...
// ...
emailObj = nil
// ------------------------------------------------------------------------
// Do the equivalent using Email.SetFromXmlText.
let sb = CkoStringBuilder()!
success = sb.loadFile(path: xmlFilePath, charset: "utf-8")
if success == false {
print("\(sb.lastErrorText!)")
return
}
let email = CkoEmail()!
success = email.set(fromXmlText: sb.getAsString())
if success == false {
print("\(email.lastErrorText!)")
return
}
}