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
(AutoIt) 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. $oMailman = ObjCreate("Chilkat.MailMan") $oMailman.MailHost = "pop.example.com" $oMailman.PopUsername = "myLogin" $oMailman.PopPassword = "myPassword" $oMailman.MailPort = 995 $oMailman.PopSsl = True ; Get the list of UIDLs for all emails in the mailbox. Local $oSa = $oMailman.GetUidls() If ($oMailman.LastMethodSuccess = False) Then ConsoleWrite($oMailman.LastErrorText & @CRLF) Exit EndIf Local $i Local $iNumEmails = $oSa.Count If ($iNumEmails = 0) Then ConsoleWrite("Mailbox is empty" & @CRLF) Exit EndIf Local $iChunkSize = 6 ; Download the emails in chunks of 6 emails each. Local $iChunkBeginIdx = 0 Local $iChunkEndIdx = $iChunkSize - 1 If ($iChunkEndIdx >= $iNumEmails) Then $iChunkEndIdx = $iNumEmails - 1 EndIf $oSaChunk = ObjCreate("Chilkat.StringArray") While ($iChunkBeginIdx < $iNumEmails) ConsoleWrite($iChunkBeginIdx & " to " & $iChunkEndIdx & @CRLF) ; Build a chunk of UIDLs. $oSaChunk.Clear For $i = $iChunkBeginIdx To $iChunkEndIdx $oSaChunk.Append($oSa.GetString($i)) Next ; Log the UIDLs in this chunk... Local $sChunkStr = $oSaChunk.SaveToText() ConsoleWrite($sChunkStr & @CRLF) ; Download this chunk of email from the POP3 server. Local $oBundle = $oMailman.FetchMultiple($oSaChunk) If ($oMailman.LastMethodSuccess = False) Then ConsoleWrite($oMailman.LastErrorText & @CRLF) Exit EndIf ConsoleWrite("Downloaded " & $oBundle.MessageCount & " emails." & @CRLF) ConsoleWrite("----" & @CRLF) ; Process the bundle... ; (your application's processing code goes here...) ; Get the next chunk... $iChunkBeginIdx = $iChunkBeginIdx + $iChunkSize $iChunkEndIdx = $iChunkEndIdx + $iChunkSize If ($iChunkEndIdx >= $iNumEmails) Then $iChunkEndIdx = $iNumEmails - 1 EndIf Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.