Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
Save Sent Email in an XML File
This example demonstrates one way of saving sent email to a single XML file. /*
The format of the "sent" XML file is:
<sent>
<email>
<date></date>
<subject></subject>
<to></to>
<mime_source></mime_source>
</email>
<email>
...
</email>
...
</sent>
The intent is to minimize the parsing so as the file grows you're not parsing
each individual email simply to load the file. You might save key information
(date,subject,to) in XML nodes, but each email's source is only parsed on
an as-needed basis.
*/
Chilkat.MailMan mailman = new Chilkat.MailMan();
mailman.UnlockComponent("anything");
mailman.SmtpHost = "smtp.comcast.net";
Chilkat.Email email = new Chilkat.Email();
email.AddTo("Chilkat Support","support@chilkatsoft.com");
email.From = "Matt Fausey <fausey@chilkatsoft.com>";
email.Subject = "This is a test";
email.Body = "This is the test body.";
mailman.SendEmail(email);
// Save the email to our "Sent" XML file.
Chilkat.Xml xmlSent = new Chilkat.Xml();
bool b = xmlSent.LoadXmlFile("sent.xml");
if (!b) {
// Initialize the XML to <sent></sent>
xmlSent.Tag = "sent";
}
Chilkat.Xml xmlEmail = xmlSent.NewChild("email","");
xmlEmail.NewChild2("date",email.EmailDate.ToString());
xmlEmail.NewChild2("subject",email.Subject);
xmlEmail.NewChild2("to",email.GetHeaderField("to"));
xmlEmail.NewChild2("mime",email.GetMime());
// Re-write the file.
xmlSent.SaveXml("sent.xml");
Important: The download for this
example does not contain the ChilkatDotNet.dll which |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.