DataFlex
DataFlex
Save an Email to a Chilkat XML File
See more Email Object Examples
Demonstrates the Chilkat Email.SaveXml method, which converts the email object to Chilkat's XML representation and saves it to a file. It can later be reloaded with LoadXml. This example builds a message and saves it as XML.
Background: This XML format is an alternative to the standard
.eml (MIME) format for persisting an email. Note that .eml also preserves Chilkat's CKX- metadata headers (which are always removed before an email is sent), so it captures the same information. Because .eml is universal and interoperable, Chilkat recommends using SaveEml / LoadEml over the XML format — even within Chilkat-based software.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoEmail
String sTemp1
Move False To iSuccess
// Demonstrates the SaveXml method, which converts the email object to Chilkat's XML
// representation and saves it to a file. It can later be reloaded with LoadXml.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "Save as XML"
Set ComFrom Of hoEmail To "alice@example.com"
Get ComAddTo Of hoEmail "Bob" "bob@example.com" To iSuccess
Set ComBody Of hoEmail To "Hello!"
// Save the email to a Chilkat XML file.
Get ComSaveXml Of hoEmail "qa_output/email.xml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Saved to email.xml."
// Note: The path "qa_output/..." is a relative local filesystem path,
// relative to the current working directory of the running application.
End_Procedure