Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Search/Download only Encrypted EmailsSearching 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.