(Tcl) Transition from MailMan.LoadXmlEmail to Email.SetFromXmlText
Provides instructions for replacing deprecated LoadXmlEmail method calls with Email.SetFromXmlText. Note: This example requires Chilkat v11.0.0 or greater.
load ./chilkat.dll
set mailman [new_CkMailMan]
# ...
# ...
set xmlFilePath "c:/test/example.xml"
# ------------------------------------------------------------------------
# The LoadXmlEmail method is deprecated:
# emailObj is a CkEmail
set emailObj [CkMailMan_LoadXmlEmail $mailman $xmlFilePath]
if {[CkMailMan_get_LastMethodSuccess $mailman] == 0} then {
puts [CkMailMan_lastErrorText $mailman]
delete_CkMailMan $mailman
exit
}
# ...
# ...
delete_CkEmail $emailObj
# ------------------------------------------------------------------------
# Do the equivalent using Email.SetFromXmlText.
set sb [new_CkStringBuilder]
set success [CkStringBuilder_LoadFile $sb $xmlFilePath "utf-8"]
if {$success == 0} then {
puts [CkStringBuilder_lastErrorText $sb]
delete_CkMailMan $mailman
delete_CkStringBuilder $sb
exit
}
set email [new_CkEmail]
set success [CkEmail_SetFromXmlText $email [CkStringBuilder_getAsString $sb]]
if {$success == 0} then {
puts [CkEmail_lastErrorText $email]
delete_CkMailMan $mailman
delete_CkStringBuilder $sb
delete_CkEmail $email
exit
}
delete_CkMailMan $mailman
delete_CkStringBuilder $sb
delete_CkEmail $email
|