Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Process Large POP3 Mailbox
Demonstrates how to read email from a mailbox that may contain a large number of emails (on the order of thousands of emails or more). LOCAL loMailman LOCAL lnSuccess LOCAL loSa LOCAL i LOCAL lnNumEmails LOCAL lnChunkBeginIdx LOCAL lnChunkEndIdx LOCAL loSaChunk LOCAL lcChunkStr LOCAL loBundle * The mailman object is used for receiving (POP3) * and sending (SMTP) email. loMailman = CreateObject('Chilkat.MailMan2') * Any string argument automatically begins the 30-day trial. lnSuccess = loMailman.UnlockComponent("30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX("Component unlock failed") QUIT ENDIF * Set the POP3 server's hostname loMailman.MailHost = "mail.chilkatsoft.com" * Set the POP3 login/password. loMailman.PopUsername = "myLogin" loMailman.PopPassword = "myPassword" * First, get the list of UIDLs for all emails in the mailbox. loSa = loMailman.GetUidls() lnNumEmails = loSa.Count * Download the emails in chunks of 10 emails each. lnChunkBeginIdx = 0 lnChunkEndIdx = 9 IF (lnChunkEndIdx >= lnNumEmails) THEN lnChunkEndIdx = lnNumEmails - 1 ENDIF loSaChunk = CreateObject('Chilkat.CkStringArray') DO WHILE (lnChunkEndIdx < (lnNumEmails - 1)) * Build a chunk of 10 UIDLs. loSaChunk.Clear() FOR i = lnChunkBeginIdx TO lnChunkEndIdx loSaChunk.Append(loSa.GetString(i)) NEXT * Display the UIDLs in this chunk... lcChunkStr = loSaChunk.SaveToText() ? lcChunkStr ? "----" + CHR(13)+CHR(10) * Download this chunk of email from the POP3 server. loBundle = loMailman.FetchMultiple(loSaChunk) IF (loBundle = NULL ) THEN =MESSAGEBOX(loMailman.LastErrorText) QUIT ENDIF * Process the bundle... * (your application's processing code goes here...) RELEASE loBundle * Get the next chunk... lnChunkBeginIdx = lnChunkBeginIdx + 10 IF (lnChunkBeginIdx >= lnNumEmails) THEN EXIT ENDIF lnChunkEndIdx = lnChunkEndIdx + 10 IF (lnChunkEndIdx >= lnNumEmails) THEN lnChunkEndIdx = lnNumEmails - 1 ENDIF ENDDO RELEASE loSa |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser