var mail = new MailMessage();
mail.Load(@"c:\data\mail.msg");
Console.WriteLine("Subject: {0}", mail.Subject);
Console.WriteLine("From: {0}", mail.From);
if (!mail.IsSigned)
{
Console.WriteLine("Mail is not signed.");
}
else
{
foreach (SubjectInfo signer in mail.Signers)
{
Console.WriteLine("Signed by: {0}", string.Join(", ", signer.Certificate.GetMailAddresses()));
}
var validity = mail.ValidateSignature();
if (validity.Valid)
{
Console.WriteLine("Signature is valid.");
}
else
{
Console.WriteLine("Signature is not valid: {0}", validity.Status);
Console.WriteLine("Certificate validation status: {0}", validity.CertificateValidationStatus);
}
}