Sample code for 30+ languages & platforms
VB.NET

Password-Encrypt an Email with AES

See more Email Object Examples

Demonstrates the Chilkat Email.AesEncrypt method, which encrypts the email body, all alternative bodies, all message sub-parts, and attachments using 128-bit AES CBC encryption. This is symmetric, password-based encryption — it does not use certificates or private keys. To decrypt, call AesDecrypt with the same password. Both the sending and receiving applications must use Chilkat and must know the shared password. This example encrypts an email.

Background: This is a Chilkat-specific convenience, distinct from standard S/MIME. Symmetric encryption means one shared secret (the password) both locks and unlocks the message — simple, but it requires a secure way to share that password out-of-band, and only Chilkat-based software can read the result. S/MIME (SendEncrypted), by contrast, uses public-key certificates and interoperates with standard mail clients. Choose AES password encryption for Chilkat-to-Chilkat exchanges where distributing a shared password is practical.

Chilkat VB.NET Downloads

VB.NET
'  Demonstrates the AesEncrypt method, which encrypts the email body, all alternative
'  bodies, all sub-parts, and attachments using 128-bit AES CBC encryption with a password.
'  This is symmetric, password-based encryption -- it does not use certificates.  Both the
'  sending and receiving applications must use Chilkat and know the same password.

Dim email As New Chilkat.Email
email.Subject = "Confidential"
email.Body = "This body will be AES-encrypted with a password."

'  Encrypt the entire email using a shared password.
email.AesEncrypt("secret_password")

'  The email content is now encrypted.  Call AesDecrypt with the same password to restore it.
Debug.WriteLine(email.GetMime())