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 Single Email by UID or Sequence Number

Assuming the UID is known, download a single email by UID from an IMAP mail server.

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.chilkatsoft.com");
    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;
    }

    CkEmail *email = 0;

    int uid;
    uid = 2014;
    bool isUid;
    isUid = true;

    email = imap.FetchSingle(uid,isUid);
    if (!(email == 0 )) {

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

        //  Display the Body property, which is the default body.
        //  If an email has an HTML body, the Body property contains
        //  the HTML source.  Otherwise it contains the plain-text
        //  body.
        printf("---- EMAIL BODY ----\n");
        printf("%s\n",email->body());
        printf("--------------------\n");

        //  Display the recipients:
        int j;
        for (j = 0; j <= email->get_NumTo() - 1; j++) {
            printf("%s, %s\n",email->getToName(j)
                ,email->getToAddr(j));
        }

        for (j = 0; j <= email->get_NumCC() - 1; j++) {
            printf("%s, %s\n",email->getCcName(j)
                ,email->getCcAddr(j));
        }

        //  Show the total size of the email, including body and attachments:
        printf("%d\n",email->get_Size());

        //  When a full email is downloaded, we would use the
        //  email.NumAttachments property in conjunction with the
        //  email.GetMailAttach* methods.
        //  However, when an email object contains only the header,
        //  we need to access the attachment info differently:
        int numAttach;
        numAttach = imap.GetMailNumAttach(*email);
        printf("%d\n",numAttach);

        for (j = 0; j <= numAttach - 1; j++) {
            printf("%s\n",imap.getMailAttachFilename(*email,j));
            int attachSize;
            attachSize = imap.GetMailAttachSize(*email,j);
            printf("    size = %d bytes\n",attachSize);
        }

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

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

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

Mail Component · .NET Mail Component · XML Parser