C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP 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

 

 

 

 

 

 

Email Attachments from In-Memory Strings

Download: Chilkat .NET Assemblies

Sample code (in C#) showing how to add email attachments directly from string variables.

// Attachments can be added directly from in-memory strings.
// This example demonstrates how it can be done...
private void AddStringAttachments()
{
    // Create an instance of the mailman.
    Chilkat.MailMan mailman = new Chilkat.MailMan();
    mailman.UnlockComponent("Anything for 30-day trial");

    // Create a new email object...
    Chilkat.Email email = new Chilkat.Email();
    email.Subject = "This is a test";
    email.Body = "This is the mail body";
    email.AddTo("Chilkat Support", "support@chilkatsoft.com");
    email.From = "Chilkat Sales <sales@chilkatsoft.com>";

    // Add some XML file attachments directly from strings in memory.
    string xml1 = "<company><name>Chilkat Software</name><industry>software</industry></company>";
    string xml2 = "<food>pizza</food>";
    
    email.AddStringAttachment("company.xml", xml1);
    email.AddStringAttachment("food.xml", xml2);
    
    // If we call ZipAttachments, the email will contain a single .zip attachment,
    // which contains two files: company.xml and food.xml.
    // If we omit the call to ZipAttachments, the email will contain two attachments:
    // company.xml and food.xml
    email.ZipAttachments("myAttach.zip");
        
    // Send the email...
    mailman.SmtpHost = "smtp.comcast.net";
   
    bool success = mailman.SendEmail(email);
    if (!success)
    {
        MessageBox.Show(mailman.LastErrorText);
    }
    else
    {
        MessageBox.Show("Mail Sent!");
    }
} 

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-2013 Chilkat Software, Inc. All Rights Reserved.