Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Save Email Attachments to a Directory
Delphi sample code showing how to save email attachments to the filesystem. // This example program shows how to read email and save attachments // to a directory. procedure TForm1.Button3Click(Sender: TObject); var email: IChilkatEmail2; bundle: IChilkatEmailBundle2; n: Integer; i: Integer; numAttach: Integer; j: Integer; begin // A ChilkatMailMan2 ActiveX component was dropped onto the Delphi // form, and this became the Form's member variable "ChilkatMailMan21". // Unlock the component -- only needs to be called once in a program. ChilkatMailMan21.UnlockComponent('Anything for 30-day trial'); // Set the POP3 mail server hostname, login, and password. ChilkatMailMan21.MailHost := 'mail.chilkatsoft.com'; ChilkatMailMan21.PopUsername := '***'; ChilkatMailMan21.PopPassword := '***'; // Read the entire mailbox, leaving the mail on the POP3 server. bundle := ChilkatMailMan21.CopyMail(); if (bundle = nil) then ShowMessage(ChilkatMailMan21.LastErrorText); // Loop over the emails in the bundle and save any attachments // in the "c:/myMailAttachments" directory. n := bundle.MessageCount; for i := 0 to n-1 do begin email := bundle.GetEmail(i); email.SaveAllAttachments('c:/myMailAttachments'); // Display each attachment filename in a listbox. numAttach := email.NumAttachments; for j := 0 to numAttach-1 do ListBox1.Items.Add(email.GetAttachmentFilename(j)); end; end;
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.