Gets or sets the algorithm for email encryption.
[Visual Basic] Public Property EncryptionAlgorithm As EncryptionAlgorithmType
[C#] public EncryptionAlgorithmType EncryptionAlgorithm {get; set;}
[C++] public: __property EncryptionAlgorithmType^ get_EncryptionAlgorithm(); public: __property void set_EncryptionAlgorithm(EncryptionAlgorithmType^);
[JScript] public function get EncryptionAlgorithm() : EncryptionAlgorithmType; public function set EncryptionAlgorithm(EncryptionAlgorithmType);
Property Value
Example
[Visual Basic, C#] The following example demonstrates how to send email with EASendMail SMTP Component. To get the full samples of EASendMail, please refer to Samples section.
[VB - Encrypt Email] Dim oMail As SmtpMail = New SmtpMail("TryIt") oMail.From = New MailAddress("test@adminsystem.com") oMail.To = New AddressCollection("encrypt1@adminsystem.com, encrypt2@adminsystem.com") For i As Integer = 0 To oMail.To.Count - 1 Dim recipient As MailAddress = oMail.To(i) Try ' Find certificate by email adddress in My Other Peoples Store. ' The certificate can be imported by *.cer file like this: ' recipient.Certificate.Load("c:\encrypt1.cer") ' Once the certificate Is loaded to MailAddress, the email content will be encrypted automatically recipient.Certificate.FindSubject(recipient.Address, Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER, "AddressBook") Catch Try ' No certificate found in AddressBook, lookup it in My recipient.Certificate.FindSubject(recipient.Address, Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER, "My") Catch ex As Exception Console.WriteLine("No encryption certificate found for {0} - {1}", recipient.Address, ex.Message) End Try End Try Next ' AES128 encryption + RSA-OAEP oMail.EncryptionAlgorithm = EncryptionAlgorithmType.ENCRYPTION_ALGORITHM_AES128
[C# - Encrypt Email] SmtpMail oMail = new SmtpMail("TryIt"); oMail.From = "test@adminsystem.com"; oMail.To = "encrypt1@adminsystem.com, encrypt2@adminsystem.com"; for (int i = 0; i < oMail.To.Count; i++) { MailAddress recipient = oMail.To[i] as MailAddress; try { // Find certificate by email adddress in My Other Peoples Store. // The certificate can be also imported by *.cer file like this: // recipient.Certificate.Load("c:\\encrypt1.cer"); // Once the certificate is loaded to MailAddress, the email content will be encrypted automatically recipient.Certificate.FindSubject(recipient.Address, Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER, "AddressBook"); } catch { try { // No certificate found in AddressBook, lookup it in My recipient.Certificate.FindSubject(recipient.Address, Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER, "My"); } catch (Exception exp) { Console.WriteLine("No encryption certificate found for {0} - {1}", recipient.Address, exp.Message); } } // AES128 encryption + RSA-OAEP oMail.EncryptionAlgorithm = EncryptionAlgorithmType.ENCRYPTION_ALGORITHM_AES128; }
[VB - Find Certificate in Active Directory by LDAP] Dim oMail As SmtpMail = New SmtpMail("TryIt") oMail.From = New MailAddress("test@adminsystem.com") oMail.To = New AddressCollection("Encryptor <encrypt@adminsystem.com>") For i As Integer = 0 To oMail.To.Count - 1 Dim recipient As MailAddress = oMail.To(i) Try ' Please change the ldap path as your environment. recipient.Certificate.FindSubject(recipient.Address, Certificate.CertificateStoreLocation.CERT_STORE_PROV_LDAP_STORE, String.Format("ldap:///CN={0},CN=USERS,DC=my,DC=server?userCertificate", recipient.Name)) Catch exp As Exception Console.WriteLine("No encryption certificate found for {0} - {1}", recipient.Address, exp.Message) End Try Next ' AES128 encryption + RSA-OAEP oMail.EncryptionAlgorithm = EncryptionAlgorithmType.ENCRYPTION_ALGORITHM_AES128
[C# - Find Certificate in Active Directory by LDAP] SmtpMail oMail = new SmtpMail("TryIt"); oMail.From = "test@adminsystem.com"; oMail.To = "Encryptor <encrypt@adminsystem.com>"; for (int i = 0; i < oMail.To.Count; i++) { MailAddress recipient = oMail.To[i] as MailAddress; try { // Please change the ldap path as your environment. recipient.Certificate.FindSubject(recipient.Address, Certificate.CertificateStoreLocation.CERT_STORE_PROV_LDAP_STORE, String.Format("ldap:///CN={0},CN=USERS,DC=my,DC=server?userCertificate", recipient.Name)); } catch (Exception exp) { Console.WriteLine("No encryption certificate found for {0} - {1}", recipient.Address, exp.Message); } } // AES128 encryption + RSA-OAEP oMail.EncryptionAlgorithm = EncryptionAlgorithmType.ENCRYPTION_ALGORITHM_AES128;
You can use EncryptionAlgorithm property to set encryption algorithm to RC2, RC4, 3DES, AES128 (RSAES-OAEP), AES192 (RSAES-OAEP) or AES256 (RSAES-OAEP).
RSA-OAEP Encryption with SHA256
If you need to use RSA-OAEP encryption with sha256 scheme, please have a look at this topic:
RSASSA-PSS + RSA-OAEP Encryption with SHA256
See Also