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

Free Support Forum - aspose.com

CryptographicException: Invalid cryptographic message type

Perhaps there’s a problem in MsgLoadOptions.DecodeSignedContent = True which will not work properly for some messages.
Run the project to see the exception and advise how to fix it?
WindowsApplication1.zip (40.2 KB)


We have logged this problem in our issue tracking system as EMAILNET-40843. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


It is to inform you that the issue you are facing is not a bug in Aspose.Email. So, we have closed the ticket EMAILNET-40843.

The original message is encrypted, so it needs to be decrypted before DecodeSignedContent. MapiMessage does not have a function for working with encrypted messages, but MailMessage does.

X509Certificate2 cert = new X509Certificate2("cert.pfx", "password");
MailMessage msg = MailMessage.Load("msg.msg");
if (msg.IsEncrypted)
    MailMessage decryptedMsg = msg.Decrypt(cert);

When reading and loading messages from pst/ost files, if we don’t use MapiMessage we’ll loose many properties, if we use, signed/encrypted messages are lost! So how do you think of adding support to MapiMessage:DecodeSignedContent for such messages?

Second, if I load the message using the given sample code, and if msg.IsEncrypted then decrypt it using MailMessage and finally pass it to the MapiMessage, we will lost many extended properties of the MapiMessage right?

Finally, can you register a feature request to add such support to MapiMessage?

Hello, @australian.dev.nerds

if we don’t use MapiMessage we’ll loose many properties, if we use, signed/encrypted messages are lost!

It isn’t exactly case for an encrypted messages. MapiMessage keeps the encrypted content as an attachment in immutable form. Therefore, it is unlikely that any properties can be lost. The decryption operations of MapiMessage and MailMessage will be identical, since we are working with the smime.p7m attachment.
For example, to decrypt MapiMessage we have to take out the smime.p7m attachment, decrypt it, then change BodyHtml, Body, MessageClass, content-type properties, etc. And it is essentially the same as converting it to MailMessage and then decrypting it.
In any case, we created the EMAILNET-40856 feature request to have method for the users convenience.