DataFlex
DataFlex
Load an Email from a Chilkat XML String
See more Email Object Examples
Demonstrates the Chilkat Email.LoadXmlString method, which loads an email from a Chilkat XML representation held in a string, typically obtained from GetXml. On success, the loaded message replaces the entire current email. This example serializes one email to XML, then reconstructs it in a second object.
Background: This is the in-memory (string) counterpart to
LoadXml, which reads from a file. Pairing GetXml with LoadXmlString lets you store an email's full state as text in a database column, cache, or message queue, then rebuild the Email object later — without touching the filesystem.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoSource
String sXmlStr
Handle hoEmail
String sTemp1
Move False To iSuccess
// Demonstrates the LoadXmlString method, which loads an email from a Chilkat XML string
// (typically obtained from GetXml). On success, the loaded message replaces the entire
// current email.
// Create an email and serialize it to Chilkat XML (as GetXml would produce).
Get Create (RefClass(cComChilkatEmail)) To hoSource
If (Not(IsComObjectCreated(hoSource))) Begin
Send CreateComObject of hoSource
End
Set ComSubject Of hoSource To "Saved email"
Set ComFrom Of hoSource To "alice@example.com"
Set ComBody Of hoSource To "Hello!"
Get ComGetXml Of hoSource To sXmlStr
// Load a new email object from the XML string.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Get ComLoadXmlString Of hoEmail sXmlStr To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComSubject Of hoEmail To sTemp1
Showln "Loaded subject: " sTemp1
End_Procedure