C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

Send Encrypted Email using a Specific Certificate

Download Chilkat .NET for 4.0 Framework

Download Chilkat .NET for 64-bit 4.0 Framework (x64)

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 64-bit 2.0 / 3.5 Framework (x64)

Download Chilkat .NET for 1.0 / 1.1 Framework

This example discusses sending encrypted email using a digital certificate that does not match the recipient's email address.

Chilkat.MailMan mailman = new Chilkat.MailMan();
mailman.UnlockComponent("anything for 30-day trial");

mailman.SmtpHost = "smtp.comcast.net";

Chilkat.Email email = new Chilkat.Email();
email.Subject = "Test encrypted mail";
email.Body = "Test encrypted mail...";
email.From = "support@chilkatsoft.com";
email.AddTo("Matt","matt@chilkatsoft.com");

// Indicate that we want the email to be sent encrypted by setting
// the SendEncrypted property = true.
// Normally, this is all that needs to be done because when SendEmail
// is called, Chilkat will locate the certificate matching the 
// recipient's email address and use it for encrypting.
email.SendEncrypted = true;

// In this case however, we will explicitly set the encryption
// certificate to one that DOES NOT MATCH the recipient's email address.
// If the email is to be received and read using an email client
// such as Outlook or Mozilla Thunderbird, this may not be OK.  When sending
// encrypted email that is to be read using these email clients, the 
// encrypting certificate usually matches the recipient's email address.
// Otherwise the recipient may not be able to decrypt and read the email.
// For the purpose of this example, Chilkat has tested with both 
// Outlook Express and Mozilla Thunderbird and found that IF the certificate
// WITH PRIVATE KEY is properly installed (from a .pfx), both email clients are able
// to decrypt and display the message.

// NOTE: You only need the public-key to encrypt an email, but you need
// the private key to decrypt.  Thus, if you intend to encrypt your email
// using your web server's SSL certificate, you would need to provide the
// private key of your SSL certificate to all potential recipients.  I hardly
// think that this is something you would want to do...

// Chilkat provides the ability to explicitly set a certificate for encrypting:
Chilkat.Cert cert = new Chilkat.Cert();
cert.LoadFromFile("myCert.cer");
email.SetEncryptCert(cert);

// Encrypt and send the email using our chosen digital certificate.
bool success = mailman.SendEmail(email);

MessageBox.Show(mailman.LastErrorText);

Important: The download for this example does not contain the ChilkatDotNet.dll which
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/vbdotnet/step2.asp

 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Email Component · XML Parser