VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++DelphiFoxProJavaPerlPythonRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Byte Array

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

Non-Chilkat Links
Text and String Handling

Reading Unread POP3 Email

The POP3 protocol does not provide the ability to ask the server which emails are "unread". Furthermore, a pure POP3 server does not even keep this information. Some servers, such as Exchange Server, expose both POP3 and IMAP interfaces. In these cases, information about read/unread status exists on the server, but it is only available via the IMAP protocol. Email clients such as Outlook and Thunderbird keep read/unread information on the client computer. This example demonstrates how UIDLs can be saved to track and read "unread" email.

Download Chilkat Email ActiveX for POP3 / SMTP

LOCAL loMailman
LOCAL lnSuccess
LOCAL loSaSeenUidls
LOCAL loSaUidls
LOCAL loSaUnseenUidls
LOCAL i
LOCAL n
LOCAL loBundle
LOCAL loEmail

*  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 = "***"
loMailman.PopPassword = "***"

*  We're keeping a list of already-seen UIDLs in a text file:
*  If this is the first time you're running this example,
*  create an empty text file named "seenUidls.txt"
loSaSeenUidls = CreateObject('Chilkat.CkStringArray')
lnSuccess = loSaSeenUidls.LoadFromFile("seenUidls.txt")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX("failed to load seenUidls.txt")
    QUIT
ENDIF

*  Get the complete list of UIDLs on the mail server.

loSaUidls = loMailman.GetUidls()

IF (loSaUidls = NULL ) THEN
    =MESSAGEBOX(loMailman.LastErrorText)
    QUIT
ENDIF

*  We don't have set operators (yet) on the StringArray object,
*  so create a new string array object (it's an object, not an actual array)
*  and add the UIDLs from saUidls that aren't already seen.
loSaUnseenUidls = CreateObject('Chilkat.CkStringArray')

n = loSaUidls.Count
FOR i = 0 TO n - 1
    IF (loSaSeenUidls.Contains(loSaUidls.GetString(i)) <> 1) THEN
        loSaUnseenUidls.Append(loSaUidls.GetString(i))
    ENDIF

NEXT

IF (loSaUnseenUidls.Count = 0) THEN
    =MESSAGEBOX("No unseen emails!")
    RELEASE loSaUidls
    QUIT
ENDIF

*  Download in full the unseen emails:

loBundle = loMailman.FetchMultiple(loSaUnseenUidls)
IF (loBundle = NULL ) THEN
    =MESSAGEBOX(loMailman.LastErrorText)
    RELEASE loSaUidls
    QUIT
ENDIF

FOR i = 0 TO loBundle.MessageCount - 1
    loEmail = loBundle.GetEmail(i)
    ? loEmail.From
    ? loEmail.Subject
    ? "----"
    RELEASE loEmail
NEXT

*  We've seen all the emails, save saUidls to "seenUidls.txt"
loSaUidls.SaveToFile("seenUidls.txt")

RELEASE loSaUidls

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