Question:
I have never tried to read email programmatically, so please excuse me if my questions sound silly. How does the Chilkat Mail know if the email being read needs to be decrypted or not.
Answer:
The structure of the MIME indicates that it is encrypted. Upon receiving an email, Chilkat Mail recognizes it and automatically locates the matching certificate w/ private key from the certificate store(s) on your computer and decrypts the email. The results of the decryption are available in these properties:
email.ReceivedEncrypted <– true if the email as received encrypted.
email.Decrypted <– true if decryption was successful.
and this method:
email.GetEncryptedByCert() <– returns the Cert object for the certificate used in decryption.
After receiving the email, the Chilkat.Email object is in the state it would be had the email been sent without encryption. This allows your program to handle encrypted and non-encrypted emails identically. (Other than checking the properties/methods I mentioned above.)
The trick to getting everything working correctly is to make sure your certificate w/private key is installed on your system properly (from a .pfx file).