We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

API Reference documentation of S/MIME support

I was looking for S/MIME support and although I can’t see it mentioned anywhere (I mean in the list of features etc.), I found posts in this forum saying that the support is there and there are methods like Encrypt, Decrypt, AttachSignature and RemoveSignature. I even found an example that does encryption: https://github.com/aspose-email/Aspose.Email-for-.NET/blob/master/Examples/CSharp/Email/EncryptAndDecryptMessage.cs
However, I see no mention of these methods in the actual API Reference: https://reference.aspose.com/net/email/aspose.email/mailmessage
Should I assume the API Reference is simply incomplete, or am I missing something?
Thanks, Vaclav


I have observed your requirements and like to inform that API reference guide is generated using automation tools and what even is available in API is specified in API reference guide. Can you please share what is issue incurring on your end.

I have no issue yet, I was simply looking for information how to implement support for S/MIME messages. So, is the Decrypt method supported or not?


Can you please elaborate your requirements that what you want to achieve using Aspose.Email. What you actually mean and where you mean to use Encrypt or Decrypt using Aspose.Email API. A working example and sample files would really be helpful to understand your requirements.

I am just asking a simple, straightforward question: is there a Decrypt method on Aspose.Email.MailMessage? If yes, why is in not documented? If not, why is it used in examples or why is it gone?
I don’t yet have any source code to demonstrate any problem, I am simply trying to understand the API before I even start coding anything.


I suggest you to please consider following sample code on your end.

    string fileName = Path.Combine(testPath, "test2.eml");
        string publicCertFile = Path.Combine(testPath, "public_cert.cer");
        string privateCertFile = Path.Combine(testPath, "private_cert.pfx");
        X509Certificate2 publicCert = new X509Certificate2(publicCertFile);
        X509Certificate2 privateCert = new X509Certificate2(privateCertFile, "123456");

        MailMessage msg = MailMessage.Load(fileName);

        MailMessage eMsg = sMsg.Encrypt(publicCert);

        MailMessage dMsg = eMsg.Decrypt(privateCert);
		dMsg.Save(fileName + ".dec.eml);

you may use:

MailMessage dMsg = eMsg.Decrypt();
dMsg.Save(fileName + ".dec.eml);

If you use Decrypt method without parameters than private certificate will be taken from certificate stores on you machine(if exists) otherwise exception will be thrown.