Sample code for 30+ languages & platforms
VB.NET

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 VB.NET Downloads

VB.NET
'  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).

Dim email As New Chilkat.Email
email.Subject = "GetXml example"
email.From = "alice@example.com"
email.AddTo("Bob","bob@example.com")
email.Body = "Hello!"

'  Convert the email to Chilkat's XML representation.
Dim xmlStr As String = email.GetXml()
Debug.WriteLine(xmlStr)