FoxPro Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
Socket
Spider
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Email Object
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
FileAccess
Bzip2
LZW
Icon

 

Non-Chilkat Links
Text and String Handling

How to Process a Large IMAP Mailbox

Demonstrates how to process a mailbox containing a large number of emails. This example was prompted by a Chilkat customer who needed to efficiently process a mailbox with over 100,000 emails. The technique is to first select the mailbox, which updates the imap.NumMessages property to reflect the number of messages in the mailbox. The emails in the mailbox have sequence numbers ranging from 1 to NumMessages. Two new methods, FetchSequence and FetchSequenceHeaders, can then be used to fetch emails based on sequence number ranges.

Download Chilkat IMAP ActiveX

LOCAL loImap
LOCAL lnSuccess
LOCAL loBundle
LOCAL lnStartSeqNum
LOCAL lnNumToFetch
LOCAL i
LOCAL loEmail


loImap = CreateObject('Chilkat.Imap')

*  Anything unlocks the component and begins a fully-functional 30-day trial.
lnSuccess = loImap.UnlockComponent("Anything for 30-day trial")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loImap.LastErrorText)
    QUIT
ENDIF

*  Connect to an IMAP server.
lnSuccess = loImap.Connect("mail.chilkatsoft.com")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loImap.LastErrorText)
    QUIT
ENDIF

*  Login
lnSuccess = loImap.Login("admin@chilkatsoft.com","*myPassword5*")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loImap.LastErrorText)
    QUIT
ENDIF

*  Our experience has been that with some IMAP servers,
*  the response time for selecting a mailbox increases with
*  the size of the mailbox.  You may need to increase the
*  ReadTimeout to a value larger than the default of 30 seconds.
*  In this case, it is set to 60 seconds.
loImap.ReadTimeout = 60

*  Select an IMAP mailbox
lnSuccess = loImap.SelectMailbox("Inbox")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loImap.LastErrorText)
    QUIT
ENDIF

*  After selecting a mailbox, the NumMessages property will
*  be updated to reflect the total number of emails in the mailbox:
? loImap.NumMessages

*  The emails in the mailbox will always have sequence numbers
*  ranging from 1 to NumMessages.  There are two new methods
*  that can be called to fetch emails for a range of sequence
*  numbers: FetchSequence and FetchSequenceHeaders.
*  They are identical except one returns full emails whereas
*  the other returns headers-only.

*  This example assumes there are more than 10 emails in the
*  mailbox and fetches the 1st 10 emails:

lnStartSeqNum = 1

lnNumToFetch = 10
loBundle = loImap.FetchSequence(lnStartSeqNum,lnNumToFetch)
IF (loBundle = NULL ) THEN
    =MESSAGEBOX(loImap.LastErrorText)
    QUIT
ENDIF

*  Print the From and Subject of each email:

FOR i = 0 TO loBundle.MessageCount - 1

    *  GetEmail does not communication with the IMAP server.
    *  It simply extracts a single email from the in-memory bundle.
    loEmail = loBundle.GetEmail(i)

    ? loEmail.From
    ? loEmail.Subject

    ? "--"
    RELEASE loEmail
NEXT

*  Disconnect from the IMAP server.
loImap.Disconnect()

RELEASE loBundle

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · ASP Mail Component · XML Parser