Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
Delete Individual Emails from POP3 MailboxDemonstrates how to delete individual emails from a POP3 mailbox.
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CHILKATMAILLib2_TLB, OleCtrls; ... procedure TForm1.Button1Click(Sender: TObject); var mailman: TChilkatMailMan2; success: Integer; bundle: CHILKATMAILLib2_TLB.IChilkatEmailBundle2; i: Integer; email: CHILKATMAILLib2_TLB.IChilkatEmail2; begin // The mailman object is used for receiving (POP3) // and sending (SMTP) email. mailman := TChilkatMailMan2.Create(Self); // Any string argument automatically begins the 30-day trial. success := mailman.UnlockComponent('Anything for 30-day trial'); if (success <> 1) then begin ShowMessage('Component unlock failed'); Exit; end; // Set the POP3 server's hostname mailman.MailHost := 'mail.chilkatsoft.com'; // Set the POP3 login/password. mailman.PopUsername := 'myLogin'; mailman.PopPassword := 'myPassword'; // Set the ImmediateDelete property = 0 // When the DeleteEmail method is called, the POP3 session // will remain open and the emails will be deleted all at once // when the session closes. mailman.ImmediateDelete := 0; // Download email headers. bundle := mailman.GetAllHeaders(1); if (bundle = nil ) then begin ShowMessage(mailman.LastErrorText); Exit; end; for i := 0 to bundle.MessageCount - 1 do begin email := bundle.GetEmail(i) As CHILKATMAILLib2_TLB.IChilkatEmail2; Memo1.Lines.Add(email.From + #13#10); Memo1.Lines.Add(email.Subject + #13#10); // If you decide the email is to be deleted, call DeleteEmail. // This marks the email for deletion on the POP3 server. success := mailman.DeleteEmail(email As CHILKATMAILLib2_TLB.IChilkatEmail2); if (success <> 1) then begin ShowMessage(mailman.LastErrorText); Exit; end; end; // Make sure the POP3 session is ended to finalize the deletes. success := mailman.Pop3EndSession(); if (success <> 1) then begin ShowMessage(mailman.LastErrorText); end; ShowMessage('Success!'); end; |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.