Generally it is all done automatically. If an email is encrypted, it is decrypted during parsing (MailBuilder.CreateFromEml). Of course you need to have proper certificates installed on your machine (StoreName.My certificate store).
To validate SMIME signature use IMail.CheckSignature method:
using (Imap imap = new Imap())
{
imap.Connect("imap.example.com"); // or ConnectSSL
imap.UseBestLogin("user", "password");
MailBuilder builder = new MailBuilder();
foreach (long uid in imap.GetAll())
{
IMail email = builder.CreateFromEml(
imap.GetMessageByUID(uid));
// Check signature
if (email.IsSigned == true)
email.CheckSignature(true);
}
imap.Close();
}
Below you can find detailed articles on this subject. They explain how to disable automatic decryption and how to use specific certificates for decryption.
Decrypt S/MIME emails:
https://www.limilabs.com/blog/decrypt-smime-emails
Validate S/MIME signed emails:
https://www.limilabs.com/blog/validate-smime-emails