ComponentPro UltimateMail

Decrypting an encrypted mail message

Language Filter: AllSend comments on this topic to ComponentPro

In order to access an encrypted message's content, you need to decrypt it first. To do that, you should check the message whether it can be decrypted or not, and then you can use the Decrypt method of the MailMessage to decrypt it. See the example below for more details:

using System;
using ComponentPro.Net.Mail;


// Create a new instance of the MailMessage class.
MailMessage msg = new MailMessage();

// Load the message from a file.

// Check to see whether the message is encrypted or not. 
if (msg.IsEncrypted)
    if (!msg.Decryptable)
        throw new ApplicationException("The message cannot be decrypted.");


// ...