Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) 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.
IncludeFile "CkImap.pb" IncludeFile "CkMessageSet.pb" IncludeFile "CkEmail.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. imap.i = CkImap::ckCreate() If imap.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Connect using TLS. CkImap::setCkSsl(imap, 1) CkImap::setCkPort(imap, 993) success.i = CkImap::ckConnect(imap,"imap.example.com") If success <> 1 Debug CkImap::ckLastErrorText(imap) CkImap::ckDispose(imap) ProcedureReturn EndIf ; Authenticate success = CkImap::ckLogin(imap,"email_account_login","email_account_password") If success <> 1 Debug CkImap::ckLastErrorText(imap) CkImap::ckDispose(imap) ProcedureReturn EndIf ; Select an IMAP mailbox success = CkImap::ckSelectMailbox(imap,"Inbox") If success <> 1 Debug CkImap::ckLastErrorText(imap) CkImap::ckDispose(imap) ProcedureReturn EndIf ; Search for messages and return a set of matching messages. ; (This example will simply search for ALL messages.) fetchUids.i = 1 messageSet.i = CkImap::ckSearch(imap,"ALL",fetchUids) If CkImap::ckLastMethodSuccess(imap) <> 1 Debug CkImap::ckLastErrorText(imap) CkImap::ckDispose(imap) ProcedureReturn EndIf Debug "Number of messages = " + Str(CkMessageSet::ckCount(messageSet)) i.i = 0 While i < CkMessageSet::ckCount(messageSet) email.i = CkImap::ckFetchSingle(imap,CkMessageSet::ckGetId(messageSet,i),fetchUids) If CkImap::ckLastMethodSuccess(imap) <> 1 Debug CkImap::ckLastErrorText(imap) CkMessageSet::ckDispose(messageSet) CkImap::ckDispose(imap) ProcedureReturn EndIf Debug CkEmail::ckFrom(email) + "; " + CkEmail::ckSubject(email) CkEmail::ckDispose(email) i = i + 1 Wend CkMessageSet::ckDispose(messageSet) Debug "OK" CkImap::ckDispose(imap) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.