+2 votes

Hello, I've found in the Forum the opposite question, how to send encrypted and digitally signed emails. I need to be able to receive encrypted and digitally signed emails.

Is it possible (if yes, how?) with Mail.dll by using IMAP?

The full use case:

  • I'm currently using IMAP
  • Check first whether an email is coming from an expected valid sender, for this purpose the email shall be encrypted and digitally signed.
  • If yes, continue reading the email

Thanks in advance for any help.


1 Answer

+1 vote

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(

        // Check signature
        if (email.IsSigned == true)

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:

Validate S/MIME signed emails:

by (298k points)