Sample code for 30+ languages & platforms
PowerBuilder

Convert an Email to Chilkat XML

See more Email Object Examples

Demonstrates the Chilkat Email.GetXml method, which converts the email object to an XML document in memory. The XML is Chilkat's own email-object representation — it is not MIME and not a standardized interchange format. This example builds a message and prints its XML.

Background: This XML form is a Chilkat-specific way to serialize an Email object that can be reloaded with LoadXml / LoadXmlString. Because it is not standard MIME, other mail software cannot read it. In practice the standard .eml format (GetMime / SaveEml) is preferred even within Chilkat-based software: .eml is interoperable and also preserves Chilkat's CKX- metadata headers (which are always removed before an email is sent), so the XML format offers no metadata advantage.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Email
string ls_XmlStr

//  Demonstrates the GetXml method, which converts the email object to an XML document in
//  memory.  The XML is Chilkat's email-object representation (not MIME and not a
//  standardized interchange format).

loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
    destroy loo_Email
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Email.Subject = "GetXml example"
loo_Email.From = "alice@example.com"
loo_Email.AddTo("Bob","bob@example.com")
loo_Email.Body = "Hello!"

//  Convert the email to Chilkat's XML representation.
ls_XmlStr = loo_Email.GetXml()
Write-Debug ls_XmlStr


destroy loo_Email