Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Search/Download only Encrypted EmailsSearching an IMAP mailbox for emails that are encrypted and download. Emails are automatically decrypted. import com.chilkatsoft.*; public class ChilkatExample { static { try { System.loadLibrary("chilkat"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load.\n" + e); System.exit(1); } } public static void main(String argv[]) { CkImap imap = new CkImap(); boolean success; // Anything unlocks the component and begins a fully-functional 30-day trial. success = imap.UnlockComponent("Anything for 30-day trial"); if (success != true) { System.out.println(imap.lastErrorText()); return; } // Connect to an IMAP server. success = imap.Connect("www.cknotes.com"); if (success != true) { System.out.println(imap.lastErrorText()); return; } // Login success = imap.Login("myLogin","myPassword"); if (success != true) { System.out.println(imap.lastErrorText()); return; } // Select an IMAP mailbox success = imap.SelectMailbox("Inbox"); if (success != true) { System.out.println(imap.lastErrorText()); return; } // An S/MIME encrypted email should have a content-type // header containing the substring "pkcs7-mime": String headerSearch; headerSearch = "HEADER Content-Type pkcs7-mime"; CkMessageSet messageSet; boolean fetchUids; fetchUids = true; messageSet = imap.Search(headerSearch,fetchUids); if (messageSet == null ) { System.out.println(imap.lastErrorText()); return; } // Download the emails indicated in the messageSet. // The emails are automatically decrypted. CkEmailBundle bundle; bundle = imap.FetchBundle(messageSet); if (bundle == null ) { System.out.println(imap.lastErrorText()); return; } // Display some information from each email: int i; for (i = 0; i <= bundle.get_MessageCount() - 1; i++) { CkEmail email; email = bundle.GetEmail(i); System.out.println(email.getHeaderField("Date")); System.out.println(email.subject()); System.out.println(email.ck_from()); System.out.println("Received Encrypted: " + email.get_ReceivedEncrypted()); if (email.get_ReceivedEncrypted() == true) { System.out.println("Successfully Decrypted: " + email.get_Decrypted()); } System.out.println("Received Signed: " + email.get_ReceivedSigned()); if (email.get_ReceivedSigned() == true) { System.out.println("Signature Verified: " + email.get_SignaturesValid()); } System.out.println("--"); } // Disconnect from the IMAP server. imap.Disconnect(); } } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.