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

 

 

 

 

 

 

 

 

Search/Download only Encrypted Emails

Searching an IMAP mailbox for emails that are encrypted and download. Emails are automatically decrypted.

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 <CkMessageSet.h>
#include <CkEmailBundle.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("www.cknotes.com");
    if (success != true) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Login
    success = imap.Login("myLogin","myPassword");
    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;
    }

    //  An S/MIME encrypted email should have a content-type
    //  header containing the substring "pkcs7-mime":
    const char * headerSearch;
    headerSearch = "HEADER Content-Type pkcs7-mime";

    CkMessageSet *messageSet = 0;
    bool fetchUids;
    fetchUids = true;
    messageSet = imap.Search(headerSearch,fetchUids);
    if (messageSet == 0 ) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Download the emails indicated in the messageSet.
    //  The emails are automatically decrypted.
    CkEmailBundle *bundle = 0;
    bundle = imap.FetchBundle(*messageSet);
    if (bundle == 0 ) {
        delete messageSet;
        printf("%s\n",imap.lastErrorText());
        return;
    }

    //  Display some information from each email:
    long i;
    for (i = 0; i <= bundle->get_MessageCount() - 1; i++) {
        CkEmail *email = 0;
        email = bundle->GetEmail(i);

        printf("%s\n",email->getHeaderField("Date"));
        printf("%s\n",email->subject());
        printf("%s\n",email->ck_from());

        printf("Received Encrypted: %d\n",email->get_ReceivedEncrypted());
        if (email->get_ReceivedEncrypted() == true) {
            printf("Successfully Decrypted: %d\n"
                ,email->get_Decrypted());
        }

        printf("Received Signed: %d\n",email->get_ReceivedSigned());
        if (email->get_ReceivedSigned() == true) {
            printf("Signature Verified: %d\n"
                ,email->get_SignaturesValid());
        }

        printf("--\n");

        delete email;
    }

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

    delete messageSet;
    delete bundle;
    }

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

Mail Component · .NET Mail Component · XML Parser