RemoveSignature Method

Can you please tell me how the RemoveSignature
method identifies which attachment in the collection is the certificate? I need to retain a copy of this certificate after I have removed it.

The signature is stored in the attachments collection and if there are multiple attachments I want to know how to identify which one is the signature.

I need to remove the signature to get at the body text of an encrypted message. But we need to keep the certificate so that users can check the authenticity of the sender by seeing the certificate.

Hi Martin,

Thank you for contacting Aspose support team.

Certificate file can be identified using the MediaType of the attachment. You may please use following sample code to identify the certificate and remove the signature using RemoveSignature().

MailMessage mail = MailMessage.Load("SubjectSigned message by Outlook.msg");

foreach(Attachment att in mail.Attachments)
{
    if (att.ContentType.MediaType == "application/pkcs7-signature")
    {
        Console.WriteLine(att.ContentType.MediaType);
        Console.WriteLine(att.ContentType.Name);
        att.Save("signature.dat");
    }
}

MailMessage unsigned = mail.RemoveSignature();