Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Read S/MIME Encrypted EmailRead S/MIME encrypted email. LOCAL loImap LOCAL lnSuccess LOCAL lnNumToFetch LOCAL loBundle LOCAL i LOCAL loEmail loImap = CreateObject('Chilkat.Imap') * Anything unlocks the component and begins a fully-functional 30-day trial. lnSuccess = loImap.UnlockComponent("Anything for 30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loImap.LastErrorText) QUIT ENDIF * Connect to an IMAP server. lnSuccess = loImap.Connect("mail.chilkatsoft.com") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loImap.LastErrorText) QUIT ENDIF * Login lnSuccess = loImap.Login("myLogin","myPassword") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loImap.LastErrorText) QUIT ENDIF * Select an IMAP mailbox lnSuccess = loImap.SelectMailbox("Inbox") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loImap.LastErrorText) QUIT ENDIF * The AutoUnwrapSecurity method controls whether signed/encrypted emails are automatically * decrypted and/or verified. * When set to 1, which is the default, security envelopes are automatically "unwrapped" * when a message is retrieved from the server. Signed emails are automatically verified, and * encrypted emails are automatically decrypted, restoring the email to the original state before * signing and/or encrypting. Information about the signing and encrypting certificates can be * retrieved from the Email object (methods: GetSignedByCert, GetEncryptedByCert; * properties: SignedBy, EncryptedBy, SignaturesValid, Decrypted, ReceivedSigned, * ReceivedEncrypted). * This example will explicity set AutoUnwrapSecurity to 1, even though it's * already the default value: loImap.AutoUnwrapSecurity = 1 * The NumMessages property contains the number of messages in the selected mailbox. lnNumToFetch = loImap.NumMessages * Download all the email in the Inbox. loBundle = loImap.FetchSequence(1,lnNumToFetch) IF (loBundle = NULL ) THEN =MESSAGEBOX(loImap.LastErrorText) QUIT ENDIF * Loop over the bundle, FOR i = 0 TO loBundle.MessageCount - 1 loEmail = loBundle.GetEmail(i) ? loEmail.From ? loEmail.Subject * At this point, if the email was signed and/or encrypted, it is already "unwrapped", i.e. * the email is already decrypted and in a state as if it were never signed or encrypted. * You may check to see if the email was received encrypted or signed, and if so, * whether it was successfully unwrapped and who signed or encrypted it: IF (loEmail.ReceivedEncrypted = 1) THEN ? "This email was encrypted when received." IF (loEmail.Decrypted = 1) THEN ? "This email was successfully decrypted. It was encrypted by:" ? loEmail.EncryptedBy ELSE ? "This email was not decrypted." ENDIF ENDIF IF (loEmail.ReceivedSigned = 1) THEN ? "This email was signed when received." IF (loEmail.SignaturesValid = 1) THEN ? "The signature was verified. It was signed by:" ? loEmail.SignedBy ELSE ? "The signature verification failed." ENDIF ENDIF * The email's body, HTML body, attachments, etc. * are decrypted and available just like any non-encrypted email. ? "--" RELEASE loEmail NEXT * Disconnect from the IMAP server. loImap.Disconnect() RELEASE loBundle |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser