C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

Save Sent Email in an XML File

Download Chilkat .NET for 4.0 Framework

Download Chilkat .NET for 64-bit 4.0 Framework (x64)

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 64-bit 2.0 / 3.5 Framework (x64)

Download Chilkat .NET for 1.0 / 1.1 Framework

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
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/vbdotnet/step2.asp

 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Email Component · XML Parser