Visual C++ Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Email Object
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

Fetch Oldest/Newest IMAP Email

Emails may be downloaded by sequence number. Assuming the selected mailbox is not empty, the oldest email is at sequence number 1, and the newest email is at sequence number N. The FetchSingle method may be used to download by sequence number.

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
#include <CkImap.h>
#include <CkEmail.h>

void ChilkatSample(void)
    {
    CkImap imap;

    bool success;

    //  Anything unlocks the component and begins a fully-functional 30-day trial.
    success = imap.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Connect to an IMAP server.
    success = imap.Connect("mail.testemail.net");
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Login
    success = imap.Login("***","***");
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Select an IMAP mailbox
    success = imap.SelectMailbox("Inbox");
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  After selecting a mailbox, the NumMessages property
    //  contains the number of emails in the selected mailbox.
    long n;
    n = imap.get_NumMessages();

    if (n > 0) {

        //  The oldest email is always at sequence number 1.
        bool isUid;
        isUid = false;

        CkEmail *oldestEmail = 0;
        oldestEmail = imap.FetchSingle(1,isUid);
        if (!(oldestEmail == 0 )) {

            //  Display the From and Subject
            printf("%s\n",oldestEmail->fromAddress());
            printf("%s\n",oldestEmail->subject());

            printf("--\n");
            delete oldestEmail;
        }

        //  The newest email is at sequence number N:
        CkEmail *newestEmail = 0;
        newestEmail = imap.FetchSingle(n,isUid);
        if (!(newestEmail == 0 )) {

            //  Display the From and Subject
            printf("%s\n",newestEmail->fromAddress());
            printf("%s\n",newestEmail->subject());

            delete newestEmail;
        }

    }

    //  Disconnect from the IMAP server.
    imap.Disconnect();
    }

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

Mail Component · .NET Mail Component · XML Parser