Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Send Email with Zipped Attachments
Perl example script to create an email with attachments and then convert the attachments to a single .zip attached file and mail. # file: ZipEmailAttachments.pl # Perl script showing how to add attachments to an email and convert # them to a single .zip attached Zip archive. use chilkat; $mailman = new chilkat::CkMailMan(); $mailman->UnlockComponent('anything for 30-day trial'); # Set the SMTP server hostname $mailman->put_SmtpHost('smtp.comcast.net'); # If your SMTP server requires a login, set username/password # $mailman->put_SmtpUsername('myUsername'); # $mailman->put_SmtpPassword('myPassword'); # Create a simple email $email = new chilkat::CkEmail(); $email->put_Subject('Sending email with a .zip attachment from Perl'); $email->put_Body('This message with Zip attachment was sent from a Perl script'); $email->put_From('Chilkat Support <support@chilkatsoft.com>'); # Add a few recipients $email->AddTo('Matt','matt@chilkatsoft.com'); $email->AddTo('TagTooga','admin@tagtooga.com'); # Add some attachments as per our previous example (EmailAttachments.pl) $contentType = new chilkat::CkString(); $success = $email->AddFileAttachment('exampleData/hamlet.xml',$contentType); $email->AddStringAttachment('test1.txt','This string is the content of test1.txt'); $email->AddStringAttachment2('test2.txt','This string is the content of test2.txt','iso-8859-1'); # You could send the email at this point in the code by calling mailman.SendEmail. # If you did, your email would have 3 attachments: test1.txt, test2.txt, and hamlet.xml # However, you could first call email.ZipAttachments like this: $email->ZipAttachments('myAttachments.zip'); # myAttachments.zip is the name of the attachment that will appear in the email. # After calling ZipAttachments, your email will contain 1 attachment # (myAttachments.zip) and within it there are three files: # test1.txt, test2.txt, and hamlet.xml. $success = $mailman->SendEmail($email); if (! $success) { $mailman->SaveLastError('lastError.txt'); } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.