Class SecureEmailManager
Contents
[
Hide
]SecureEmailManager class
Provides methods for working with secure emails, including S/MIME signing and encryption operations. This class enables digital signature verification, message decryption, and signing of email messages using X.509 certificates and PKCS#7/CMS standards.
public class SecureEmailManager
Constructors
| Name | Description |
|---|---|
| SecureEmailManager() | The default constructor. |
Methods
| Name | Description |
|---|---|
| virtual AttachSignature(MailMessage, CmsSigner) | Creates a signed copy of the message (S/MIME). |
| virtual AttachSignature(MailMessage, X509Certificate2) | Creates a signed copy of the message (S/MIME). |
| virtual AttachSignature(MapiMessage, CmsSigner) | Creates a signed copy of the message (S/MIME). |
| virtual AttachSignature(MapiMessage, X509Certificate2) | Creates a signed copy of the message (S/MIME). |
| virtual AttachSignature(MailMessage, CmsSigner, SignatureOptions) | Creates a signed copy of the message (S/MIME) with the specified options. |
| virtual AttachSignature(MailMessage, X509Certificate2, SignatureOptions) | Creates a signed copy of the message (S/MIME) with the specified options. |
| virtual AttachSignature(MapiMessage, CmsSigner, SignatureOptions) | Creates a signed copy of the message (S/MIME) with the specified options. |
| virtual AttachSignature(MapiMessage, X509Certificate2, SignatureOptions) | Creates a signed copy of the message (S/MIME) with the specified options. |
| CheckSignature(MailMessage) | Verifies the signature of the message. |
| CheckSignature(MapiMessage) | Verifies the signature of the message. |
| CheckSignature(MailMessage, X509Certificate2) | Verifies the signature of the message, decrypting it first if needed. |
| CheckSignature(MapiMessage, X509Certificate2) | Verifies the signature of the message, decrypting it first if needed. |
| CheckSignature(MailMessage, X509Certificate2, X509Store) | Verifies the signature of the message, decrypting it first if needed. |
| CheckSignature(MapiMessage, X509Certificate2, X509Store) | Verifies the signature of the message, decrypting it first if needed. |
Remarks
Use CheckSignature to verify digital signatures on MailMessage or MapiMessage objects and retrieve signing/encryption certificates. Use AttachSignature methods to digitally sign messages using X.509 certificates or CmsSigner objects. Supports both attached (enveloped) and detached signature formats, as well as message encryption and decryption.
Examples
This example signs a message and verifies the signature.
[C#]
var certificate = new X509Certificate2("signer.pfx", "password");
var manager = new SecureEmailManager();
var msg = new MailMessage("from@example.com", "to@example.com", "Signed message", "Hello");
MailMessage signed = manager.AttachSignature(msg, certificate, new SignatureOptions { Detached = true });
signed.Save("signed.eml");
SmimeResult result = manager.CheckSignature(MailMessage.Load("signed.eml"));
Console.WriteLine(result.IsSuccess ? "The signature is valid." : "The signature is not valid: " + result.Error);
[Visual Basic]
Dim certificate = New X509Certificate2("signer.pfx", "password")
Dim manager = New SecureEmailManager()
Dim msg = New MailMessage("from@example.com", "to@example.com", "Signed message", "Hello")
Dim signed As MailMessage = manager.AttachSignature(msg, certificate, New SignatureOptions With {.Detached = True})
signed.Save("signed.eml")
Dim result As SmimeResult = manager.CheckSignature(MailMessage.Load("signed.eml"))
Console.WriteLine(If(result.IsSuccess, "The signature is valid.", "The signature is not valid: " & result.Error.ToString()))
See Also
- namespace Aspose.Email
- assembly Aspose.Email