Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkEmailW.h>
void ChilkatSample(void)
{
BOOL success;
HCkEmailW email;
success = FALSE;
// 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.
email = CkEmailW_Create();
CkEmailW_putSubject(email,L"Save as XML");
CkEmailW_putFrom(email,L"alice@example.com");
CkEmailW_AddTo(email,L"Bob",L"bob@example.com");
CkEmailW_putBody(email,L"Hello!");
// Save the email to a Chilkat XML file.
success = CkEmailW_SaveXml(email,L"qa_output/email.xml");
if (success == FALSE) {
wprintf(L"%s\n",CkEmailW_lastErrorText(email));
CkEmailW_Dispose(email);
return true;
}
wprintf(L"Saved to email.xml.\n");
// Note: The path "qa_output/..." is a relative local filesystem path,
// relative to the current working directory of the running application.
CkEmailW_Dispose(email);
}