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
(Lianja) Process Large POP3 MailboxDemonstrates how to read email from a mailbox that may contain a large number of emails.
// This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loMailman = createobject("CkMailMan") loMailman.MailHost = "pop.example.com" loMailman.PopUsername = "myLogin" loMailman.PopPassword = "myPassword" loMailman.MailPort = 995 loMailman.PopSsl = .T. // Get the list of UIDLs for all emails in the mailbox. loSa = loMailman.GetUidls() if (loMailman.LastMethodSuccess = .F.) then ? loMailman.LastErrorText release loMailman return endif lnNumEmails = loSa.Count if (lnNumEmails = 0) then ? "Mailbox is empty" release loMailman return endif lnChunkSize = 6 // Download the emails in chunks of 6 emails each. lnChunkBeginIdx = 0 lnChunkEndIdx = lnChunkSize - 1 if (lnChunkEndIdx >= lnNumEmails) then lnChunkEndIdx = lnNumEmails - 1 endif loSaChunk = createobject("CkStringArray") do while (lnChunkBeginIdx < lnNumEmails) ? str(lnChunkBeginIdx) + " to " + str(lnChunkEndIdx) // Build a chunk of UIDLs. loSaChunk.Clear() for i = lnChunkBeginIdx to lnChunkEndIdx loSaChunk.Append(loSa.GetString(i)) next // Log the UIDLs in this chunk... lcChunkStr = loSaChunk.SaveToText() ? lcChunkStr // Download this chunk of email from the POP3 server. loBundle = loMailman.FetchMultiple(loSaChunk) if (loMailman.LastMethodSuccess = .F.) then ? loMailman.LastErrorText release loMailman release loSaChunk return endif ? "Downloaded " + str(loBundle.MessageCount) + " emails." ? "----" // Process the bundle... // (your application's processing code goes here...) release loBundle // Get the next chunk... lnChunkBeginIdx = lnChunkBeginIdx + lnChunkSize lnChunkEndIdx = lnChunkEndIdx + lnChunkSize if (lnChunkEndIdx >= lnNumEmails) then lnChunkEndIdx = lnNumEmails - 1 endif enddo release loSa release loMailman release loSaChunk |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.