Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
Send Encrypted Email in C#
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 From 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!";
}
}
Important: The download for this
example does not contain the ChilkatDotNet.dll which
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.