Smime Class
Provides properties and methods for encrypting, decrypting, signing and verifying e-mail messages.
Inheritance Hierarchy

Namespace: MailBee.Security
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public class Smime

The Smime type exposes the following members.

Public methodSmime
Creates an instance of Smime class.
Public methodSmime(String)
Creates and unlocks an instance of Smime class.
Public methodCode exampleDecrypt(MailMessage)
Decrypts an e-mail message if it's encrypted.
Public methodCode exampleDecrypt(MailMessage, CertificateStore)
Decrypts an e-mail message if it's encrypted.
Public methodCode exampleDecryptAndVerify(MailMessage, MessageVerificationFlags)
Decrypts an e-mail message if it's encrypted and verifies its signature if it's signed.
Public methodCode exampleDecryptAndVerify(MailMessage, MessageVerificationFlags, CertificateStore, CertificateStore)
Decrypts an e-mail message if it's encrypted and verifies its signature if it's signed.
Public methodCode exampleEncrypt
Encrypts an e-mail message.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleResetToDefaults
Resets S/MIME settings to default values.
Public methodCode exampleSign
Signs an e-mail message with a digital signature.
Public methodCode exampleSignAndEncrypt
Signs and encrypts an e-mail message.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodCode exampleVerify
Verifies if the signature of the specified e-mail message is valid.
Public propertyCode exampleEncryptionAlgorithm
Gets or sets the algorithm to use for encrypting messages.
Public propertyCode exampleHashAlgorithm
Gets or sets the hash algorithm to use for signing messages with a digital signature.
Public propertyLastResult
Gets a numeric code of the last error.
Public propertyCode exampleProvider
Gets or sets the CSP to be used for cryptographic operations.
Public propertySetEnvelopedCmsOnDecrypt
Gets or sets if Decrypt(MailMessage) or DecryptAndVerify(MailMessage, MessageVerificationFlags) methods should also populate EnvelopedCmsResult property.
Public propertySetSignedCmsOnVerify
Public propertyThrowExceptions
Gets or sets whether the object will throw exceptions on errors.
Using this class, you can perform the following operations with e-mail messages:
  • Encrypt or decrypt e-mails
  • Sign e-mails with a digital signature
  • Verify signatures of e-mails

The class by default uses FIPS compliant algorithms: RSA DES for encryption and SHA1 for signing.

Note Note
To use this class, make sure MailBee.NET Security is licensed (MailBee.NET Objects full bundle does include the license).
This sample retrieves the last e-mail from the specified POP3 account, decrypts it if it's encrypted and verifies its signature if any. Then, it prints the plain-text version of the message to the console.
// 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);

    if (msg.IsEncrypted)
        SmimeResult smResult = objSmime.DecryptAndVerify(msg, MessageVerificationFlags.All);
        if (smResult.VerificationResult > 0)
            Console.WriteLine("Verification failed");
        else if (smResult.DecryptedMessage != null)
catch (MailBeeException ex)
See Also