Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Send Email with Zipped Attachments
Delphi example code to create an email with file attachments, zip them in-memory to create a single .zip attachment, and send. // Create an email with file attachments, then replace them with // a single .zip file attachment. procedure TForm1.Button15Click(Sender: TObject); var email: IChilkatEmail2; ok: Integer; begin // A ChilkatMailMan2 ActiveX component was dropped onto the Delphi // form, and this became the Form's member variable "ChilkatMailMan21". ChilkatMailMan21.UnlockComponent('Anything for 30-day trial'); ChilkatMailMan21.SmtpHost := 'smtp.comcast.net'; email := ChilkatMailMan21.NewEmail(); email.Subject := 'Email with attachments sent from a Delphi program!'; email.From := 'Chilkat Support <support@chilkatsoft.com>'; email.AddTo('Chilkat Admin','admin@chilkatsoft.com'); email.Body := 'This email was sent from a Delphi program...'; // Add a few file attachments. email.AddFileAttachment('dude.gif'); email.AddFileAttachment('fw9.pdf'); // Add an attachment directly from an in-memory string. email.AddStringAttachment('test.xml','<test><companyName>Chilkat Software</companyName></test>'); // The following call to ZipAttachments replaces the 3 existing attachments with // a single "attachments.zip" file attachment. The contents of "attachments.zip" // are dude.gif, fw9.pdf, and test.xml. NOTE: The "attachments.zip" file never exists // no the filesystem. It is created completely in-memory. The receiving email client // will receive an email with a valid .zip attachment, which can be unzipped to retrieve // the files contained within. email.ZipAttachments('attachments.zip'); ok := ChilkatMailMan21.SendEmail(email); if (ok = 0) then ChilkatMailMan21.SaveLastError('errorLog.xml'); end;
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.