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 in C#

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 is a simple example demonstrating how to send encrypted mail via an SMTP server in C#.

private void SendEncrypted_Click(object sender, System.EventArgs e)
{
	// Create a mailman object for sending email.
	Chilkat.MailMan mailman = new Chilkat.MailMan();
	mailman.UnlockComponent("UnlockCode");

	mailman.SmtpHost = "smtp.earthlink.net";
	// The SMTP username and password are only necessary if
	// your SMTP server requires authentication.
	//mailman.SmtpUsername = "myLogin";
	//mailman.SmtpPassword = "myPassword";

	// Create an email object
	Chilkat.Email email = new Chilkat.Email();
	email.Subject = "This is the subject";
	email.Body = "This is the body";
	email.AddTo("Chilkat Support","support@chilkatsoft.com");
	email.From = "John Smith <john@chilkatsoft.com>";

	// If a certificate matching the TO email address exists in
	// the any of the following certificate stores, then Chilkat Mail
	// will automatically find it, select it, and encrypt the email with
	// it.
	//	1) Local Machine Certificate Store
	//  2) Current User Certificate Store
	//  3) Outlook Certificate Store
	// 
	// For more information in general, see http://www.chilkatsoft.com/smime.asp
	email.SendEncrypted = true;

	// You can also specifically load a certificate from a file in
	// any one of the following formats:
	// 1) DER encoded binary X.509 (.CER)
	// 2) Base-64 encoded X.509 (.CER)
	// 3) Cryptographic Message Syntax Standard - PKCS #7 Certificates (.P7B)
	//Chilkat.Cert cert = new Chilkat.Cert();
	//cert.LoadFromFile("myCert.cer");
	//email.SetEncryptCert(cert);

	Status.Text = "Sending email...";
	Status.Refresh();
	bool success = mailman.SendEmail(email);
	if (!success) 
	{
		Status.Text = "Send Failed, check sendError.xml";
		mailman.SaveLastError("sendError.xml");
	}
	else
	{
		Status.Text = "Success!";
	}
}

 

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

Email Component · XML Parser