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.
Chilkat.Imap imap = new Chilkat.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) { MessageBox.Show(imap.LastErrorText); return; } // Connect to an IMAP server. success = imap.Connect("www.cknotes.com"); if (success != true) { MessageBox.Show(imap.LastErrorText); return; } // Login success = imap.Login("myLogin","myPassword"); if (success != true) { MessageBox.Show(imap.LastErrorText); return; } // Select an IMAP mailbox success = imap.SelectMailbox("Inbox"); if (success != true) { MessageBox.Show(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"; Chilkat.MessageSet messageSet = null; bool fetchUids; fetchUids = true; messageSet = imap.Search(headerSearch,fetchUids); if (messageSet == null ) { MessageBox.Show(imap.LastErrorText); return; } // Download the emails indicated in the messageSet. // The emails are automatically decrypted. Chilkat.EmailBundle bundle = null; bundle = imap.FetchBundle(messageSet); if (bundle == null ) { MessageBox.Show(imap.LastErrorText); return; } // Display some information from each email: int i; for (i = 0; i <= bundle.MessageCount - 1; i++) { Chilkat.Email email = null; email = bundle.GetEmail(i); textBox1.Text += email.GetHeaderField("Date") + "\r\n"; textBox1.Text += email.Subject + "\r\n"; textBox1.Text += email.From + "\r\n"; textBox1.Text += "Received Encrypted: " + email.ReceivedEncrypted + "\r\n"; if (email.ReceivedEncrypted == true) { textBox1.Text += "Successfully Decrypted: " + email.Decrypted + "\r\n"; } textBox1.Text += "Received Signed: " + email.ReceivedSigned + "\r\n"; if (email.ReceivedSigned == true) { textBox1.Text += "Signature Verified: " + email.SignaturesValid + "\r\n"; } textBox1.Text += "--" + "\r\n"; } // Disconnect from the IMAP server. imap.Disconnect(); |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.