+1 vote

I have purchase your Mail.dll .NET library and I say it's good job ... :)

I have a problem for decrypt S/MIME mail.

When I check the mail, I can decrypt the Body (Text message) of the mail but the field to, from and Subject is empty ?

See output of compile :

Subject:
De :
A :
LE :

by

1 Answer

0 votes
 
Best answer

Most likely this means, that those fields are not present in an encrypted email.

SMIME encryption works in such way that the encrypted message is wrapped in regular mail message. This outer message has all required mail headers (From, To, Subject and so on). Those headers are in plain text and visible to others during transport.

Encrypted message, that is encapsulated, is not visible of course.

You can use MailBuilder's DecryptAutomatically property to prevent automatic decryption. This gives you opportunity to access mail headers before the encrypted mail is extracted.

byte[] eml = imap.GetMessageByUID(...);

MailBuilder builder = new MailBuilder();
builder.SMIMEConfiguration.DecryptAutomatically = false;
IMail mail = builder.CreateFromEml(eml);

IList<MailAddress> to = mail.To; // visible during transport
string subject = mail.Subject;   // visible during transport

if (mail.NeedsDecryption == true)
{
    IMail decrypted = mail.Decrypt();
    IList<MailAddress> decryptedTo = decrypted.To;
    string decryptedSubject = decrypted.Subject;
}
by (297k points)
...