By default MailBuilder
tries to automatically decrypt emails.
It uses current account's/local machine's key store.
It is the store that prompts you for the password.
When you placed the certificate in the store you specifically asked it to
- prompt you for password every time private key is accessed and
- for the private key to be non-exportable.
What you are trying to do now is to bypass Windows security - most likely you will not succeed.
Your options are:
- export certificate to pfx file and provide it directly to Mail.dll
- place the certificate in the store without 'ask for password every time I used it' option checked:
You can provide the certificate (with private key) from code:
X509Certificate2 certificate = new X509Certificate2(
@"certificate.pfx",
"PFX-PASSWORD-GOES-HERE",
X509KeyStorageFlags.PersistKeySet);
MailBuilder builder = new MailBuilder();
builder.SMIMEConfiguration.Certificates.Add(certificate);
IMail decrypted= builder.CreateFromEml(eml);