Chilkat HOME Android™ ASP Visual Basic VB.NET C# iOS (IPhone) Objective-C C++ C Unicode C++ Unicode C MFC Delphi DLL Delphi ActiveX FoxPro Java Perl PHP Extension PHP ActiveX Python PowerShell Ruby SQL Server VBScript
Email Attachments from In-Memory StringsDownload: 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 |
© 2000-2013 Chilkat Software, Inc. All Rights Reserved.