MailMessage.AttachSignature

AttachSignature(X509Certificate2, bool)

Creates a signed message. Creates a read-only copy of the specified MailMessage and adds a digital signature to it.

public virtual MailMessage AttachSignature(X509Certificate2 certificate, bool detached)
ParameterTypeDescription
certificateX509Certificate2X.509 certificate.
detachedBoolean.If detached is true, the signature is detached.If detached is false(the default), the signature is not detached.

See Also


AttachSignature(CmsSigner, bool)

Creates a signed message. Creates a read-only copy of the specified MailMessage and adds a digital signature to it.

public virtual MailMessage AttachSignature(CmsSigner signer, bool detached)
ParameterTypeDescription
signerCmsSignerSystem.Security.Cryptography.Pkcs.CmsSigner.
detachedBoolean.If detached is true, the signature is detached.If detached is false(the default), the signature is not detached.

Return Value

The signed MailMessage.

See Also


AttachSignature(X509Certificate2)

Creates a signed message. Creates a read-only copy of the specified MailMessage and adds a digital signature to it.

public virtual MailMessage AttachSignature(X509Certificate2 certificate)
ParameterTypeDescription
certificateX509Certificate2X.509 certificate.

Return Value

The signed MailMessage.

Examples

The following example shows how to attach a Certificate with AttachSignature Method.

[C#]

var privateCertFile = "MartinCertificate.pfx";
var privateCert = new X509Certificate2(privateCertFile, "anothertestaccount");
var msg = new MailMessage("user@domain.com", "receiver@domain.com", "subject:Signed message only by AE", "body:Test Body of signed message by AE");
var signed = msg.AttachSignature(privateCert, true);

[Visual Basic]

Dim privateCertFile = "MartinCertificate.pfx"
Dim privateCert = New X509Certificate2(privateCertFile, "anothertestaccount")
Dim msg = New MailMessage("user@domain.com", "receiver@domain.com", "subject:Signed message only by AE", "body:Test Body of signed message by AE")
Dim signed = msg.AttachSignature(privateCert, True)

See Also


AttachSignature(CmsSigner)

Creates a signed message. Creates a read-only copy of the specified MailMessage and adds a digital signature to it.

public virtual MailMessage AttachSignature(CmsSigner signer)
ParameterTypeDescription
signerCmsSignerSystem.Security.Cryptography.Pkcs.CmsSigner.

Return Value

The signed MailMessage.

See Also