![]() |
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
(Visual FoxPro) How to Download Messages in MessageSet One at a TimeIf a message set contains a huge number of emails, it's NOT a good idea to try to download all at once into an email bundle using a method such as FetchBundle. It's better to iterate over the messages in the set to download one by one. Note: This example requires Chilkat v11.0.0 or greater.
LOCAL lnSuccess LOCAL loImap LOCAL lnFetchUids LOCAL loMessageSet LOCAL loEmail LOCAL i lnSuccess = 0 * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. loImap = CreateObject('Chilkat.Imap') * Connect using TLS. loImap.Ssl = 1 loImap.Port = 993 lnSuccess = loImap.Connect("imap.example.com") IF (lnSuccess = 0) THEN ? loImap.LastErrorText RELEASE loImap CANCEL ENDIF * Authenticate lnSuccess = loImap.Login("email_account_login","email_account_password") IF (lnSuccess = 0) THEN ? loImap.LastErrorText RELEASE loImap CANCEL ENDIF * Select an IMAP mailbox lnSuccess = loImap.SelectMailbox("Inbox") IF (lnSuccess = 0) THEN ? loImap.LastErrorText RELEASE loImap CANCEL ENDIF * Search for messages and return a set of matching messages. * (This example will simply search for ALL messages.) lnFetchUids = 1 loMessageSet = CreateObject('Chilkat.MessageSet') lnSuccess = loImap.QueryMbx("ALL",lnFetchUids,loMessageSet) IF (lnSuccess = 0) THEN ? loImap.LastErrorText RELEASE loImap RELEASE loMessageSet CANCEL ENDIF ? "Number of messages = " + STR(loMessageSet.Count) loEmail = CreateObject('Chilkat.Email') i = 0 DO WHILE i < loMessageSet.Count lnSuccess = loImap.FetchEmail(0,loMessageSet.GetId(i),lnFetchUids,loEmail) IF (lnSuccess = 0) THEN ? loImap.LastErrorText RELEASE loImap RELEASE loMessageSet RELEASE loEmail CANCEL ENDIF ? loEmail.From + "; " + loEmail.Subject i = i + 1 ENDDO ? "OK" RELEASE loImap RELEASE loMessageSet RELEASE loEmail |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.