![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Lianja) Delete All IMAP EmailDemonstrates two ways to delete all email in a mailbox on an IMAP server. Note: This example requires Chilkat v11.0.0 or greater.
llSuccess = .F. // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loImap = createobject("CkImap") // Turn on session logging: loImap.KeepSessionLog = .T. // Connect to an IMAP server. // Use TLS loImap.Ssl = .T. loImap.Port = 993 llSuccess = loImap.Connect("imap.example.com") if (llSuccess = .F.) then ? loImap.LastErrorText release loImap return endif // Login llSuccess = loImap.Login("myLogin","myPassword") if (llSuccess = .F.) then ? loImap.LastErrorText release loImap return endif // Select an IMAP mailbox llSuccess = loImap.SelectMailbox("Inbox.RubyMail") if (llSuccess = .F.) then ? loImap.LastErrorText release loImap return endif // Get the complete set of Uids for email in the selected mailbox. loMessageSet = createobject("CkMessageSet") llSuccess = loImap.QueryMbx("ALL",.T.,loMessageSet) if (llSuccess = .F.) then ? loImap.LastErrorText release loImap release loMessageSet return endif // Set the Deleted flag for each message. // (ExpungeAndClose must be called to finalize the delete.) llSuccess = loImap.SetFlags(loMessageSet,"Deleted",1) if (llSuccess = .F.) then ? loImap.LastErrorText release loImap release loMessageSet return endif // Alternatively, the Deleted flag may be set for each UID // individiually, but this is less efficient: i = 0 n = loMessageSet.Count do while i < n llSuccess = loImap.SetFlag(loMessageSet.GetId(i),loMessageSet.HasUids,"Deleted",1) if (llSuccess = .F.) then ? loImap.LastErrorText release loImap release loMessageSet return endif i = i + 1 enddo // Expunge and close the mailbox. llSuccess = loImap.ExpungeAndClose() if (llSuccess = .F.) then ? loImap.LastErrorText release loImap release loMessageSet return endif // Display the session log. ? loImap.SessionLog // Disconnect from the IMAP server. llSuccess = loImap.Disconnect() release loImap release loMessageSet |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.