Smime Class |
Namespace: MailBee.Security
The Smime type exposes the following members.
Name | Description | |
---|---|---|
Smime |
Creates an instance of Smime class.
| |
Smime(String) |
Creates and unlocks an instance of Smime class.
|
Name | Description | |
---|---|---|
Decrypt(MailMessage) |
Decrypts an e-mail message if it's encrypted.
| |
Decrypt(MailMessage, CertificateStore) |
Decrypts an e-mail message if it's encrypted.
| |
Decrypt2 |
Decrypts an e-mail message if it's encrypted.
| |
DecryptAndVerify(MailMessage, MessageVerificationFlags) |
Decrypts an e-mail message if it's encrypted and verifies its signature if it's signed.
| |
DecryptAndVerify(MailMessage, MessageVerificationFlags, CertificateStore, CertificateStore) |
Decrypts an e-mail message if it's encrypted and verifies its signature if it's signed.
| |
DecryptAndVerify2 |
Decrypts an e-mail message if it's encrypted and verifies its signature if it's signed.
| |
Encrypt |
Encrypts an e-mail message.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ResetToDefaults |
Resets S/MIME settings to default values.
| |
Sign(MailMessage, Certificate) |
Signs an e-mail message with a digital signature.
| |
Sign(MailMessage, Certificate, CertificateCollection) |
Signs an e-mail message with a digital signature, with the ability to provide a user-defined chain of signing certificates.
| |
SignAndEncrypt(MailMessage, Certificate, CertificateCollection) |
Signs and encrypts an e-mail message.
| |
SignAndEncrypt(MailMessage, Certificate, CertificateCollection, CertificateCollection) |
Signs and encrypts an e-mail message, with the ability to provide a user-defined chain of signing certificates.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Verify |
Verifies if the signature of the specified e-mail message is valid.
| |
Verify2 |
Verifies if the signature of the specified e-mail message is valid.
|
The class by default uses FIPS compliant algorithms: RSA DES for encryption and SHA1 for signing (although you can set other algorithms like AES-256 for encryption with and SHA256 for signing with EncryptionAlgorithm and HashAlgorithm properties).
Note |
---|
To use this class, make sure MailBee.NET Security is licensed (MailBee.NET Objects full bundle does include the license). |
Note |
---|
The methods of this class work a bit differently in different editions of MailBee.NET Objects. .NET Standard 2.0 version is based on EnvelopedCms class but it's not available in .NET Core 1.0/1.1 (where Win32 Interop is used instead). .NET Framework edition supports both EnvelopedCms way of doing things and Win32 Interop. UWP version prior to Windows 10 Fall Creators update doesn't support Smime class at all. |
In .NET Standard 2.0 and higher (including .NET Core 2.0 and higher), use methods which have "2" suffix in their name. This includes Decrypt2(MailMessage, X509Certificate2Collection), Verify2(MailMessage, MessageVerificationFlags, X509Certificate2Collection), DecryptAndVerify2(MailMessage, MessageVerificationFlags, X509Certificate2Collection, X509Certificate2Collection).
// To use the code below, import these namespaces at the top of your code using System; using MailBee; using MailBee.Pop3Mail; using MailBee.Mime; using MailBee.Security; Smime objSmime = new Smime(); Pop3 pop = new Pop3(); pop.Connect("server", 110, true); pop.Login("login", "password"); MailMessage msg = pop.DownloadEntireMessage(pop.InboxMessageCount); pop.Disconnect(); try { if (msg.IsEncrypted) { SmimeResult smResult = objSmime.DecryptAndVerify(msg, MessageVerificationFlags.All); if (smResult.VerificationResult > 0) { Console.WriteLine("Verification failed"); } else if (smResult.DecryptedMessage != null) { Console.WriteLine(smResult.DecryptedMessage.BodyPlainText); } } } catch (MailBeeException ex) { Console.WriteLine(ex.Message); }