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
(DataFlex) Process Large POP3 MailboxDemonstrates how to read email from a mailbox that may contain a large number of emails.
Use ChilkatAx-win32.pkg Procedure Test Handle hoMailman Variant vSa Handle hoSa Integer i Integer iNumEmails Integer iChunkSize Integer iChunkBeginIdx Integer iChunkEndIdx Variant vSaChunk Handle hoSaChunk Boolean iSuccess String sChunkStr Variant vBundle Handle hoBundle String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatMailMan)) To hoMailman If (Not(IsComObjectCreated(hoMailman))) Begin Send CreateComObject of hoMailman End Set ComMailHost Of hoMailman To "pop.example.com" Set ComPopUsername Of hoMailman To "myLogin" Set ComPopPassword Of hoMailman To "myPassword" Set ComMailPort Of hoMailman To 995 Set ComPopSsl Of hoMailman To True // Get the list of UIDLs for all emails in the mailbox. Get ComGetUidls Of hoMailman To vSa If (IsComObject(vSa)) Begin Get Create (RefClass(cComCkStringArray)) To hoSa Set pvComObject Of hoSa To vSa End Get ComLastMethodSuccess Of hoMailman To bTemp1 If (bTemp1 = False) Begin Get ComLastErrorText Of hoMailman To sTemp1 Showln sTemp1 Procedure_Return End Get ComCount Of hoSa To iNumEmails If (iNumEmails = 0) Begin Showln "Mailbox is empty" Procedure_Return End Move 6 To iChunkSize // Download the emails in chunks of 6 emails each. Move 0 To iChunkBeginIdx Move (iChunkSize - 1) To iChunkEndIdx If (iChunkEndIdx >= iNumEmails) Begin Move (iNumEmails - 1) To iChunkEndIdx End Get Create (RefClass(cComCkStringArray)) To hoSaChunk If (Not(IsComObjectCreated(hoSaChunk))) Begin Send CreateComObject of hoSaChunk End While (iChunkBeginIdx < iNumEmails) Showln iChunkBeginIdx " to " iChunkEndIdx // Build a chunk of UIDLs. Send ComClear To hoSaChunk For i From iChunkBeginIdx To iChunkEndIdx Get ComGetString Of hoSa i To sTemp1 Get ComAppend Of hoSaChunk sTemp1 To iSuccess Loop // Log the UIDLs in this chunk... Get ComSaveToText Of hoSaChunk To sChunkStr Showln sChunkStr // Download this chunk of email from the POP3 server. Get pvComObject of hoSaChunk to vSaChunk Get ComFetchMultiple Of hoMailman vSaChunk To vBundle If (IsComObject(vBundle)) Begin Get Create (RefClass(cComChilkatEmailBundle)) To hoBundle Set pvComObject Of hoBundle To vBundle End Get ComLastMethodSuccess Of hoMailman To bTemp1 If (bTemp1 = False) Begin Get ComLastErrorText Of hoMailman To sTemp1 Showln sTemp1 Procedure_Return End Get ComMessageCount Of hoBundle To iTemp1 Showln "Downloaded " iTemp1 " emails." Showln "----" // Process the bundle... // (your application's processing code goes here...) Send Destroy of hoBundle // Get the next chunk... Move (iChunkBeginIdx + iChunkSize) To iChunkBeginIdx Move (iChunkEndIdx + iChunkSize) To iChunkEndIdx If (iChunkEndIdx >= iNumEmails) Begin Move (iNumEmails - 1) To iChunkEndIdx End Loop Send Destroy of hoSa End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.