Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Visual C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
FileAccess
Bzip2
LZW
Icon

 

 

 

 

 

 

 

 

Send 168-bit 3DES Encrypted Email

Demonstrates how to send 3DES encrypted mail.

// Send a 3DES encrypted email
void EmailExample(void)
    {
    CkMailMan mailman;

    // Any string passed to UnlockComponent begins the 30-day trial.
    bool unlocked = mailman.UnlockComponent("30-day trial");
    if (!unlocked)
	{
	printf("Failed to unlock component\n");
	return;
	}

    mailman.put_SmtpHost("mail.earthlink.net");
    
    // Send a 3DES 168-bit encrypted email.
    CkEmail email;

    email.put_Body("This is the encrypted email body");

    email.put_FromAddress("matt@chilkatsoft.com");
    
    email.put_Subject("This is the email subject");

    // Load a certificate from a file and use it for encrypting.
    CkCert cert;
    cert.LoadFromFile("myCert.cer");

    // The To address must match the email address in the certificate:
    email.AddTo("Chilkat Support","support@chilkatsoft.com");

    // Check to make sure the certificate's email address matches.
    CkString certEmailAddr;
    cert.get_SubjectE(certEmailAddr);
    if (!certEmailAddr.equals("support@chilkatsoft.com"))
	{
	printf("Certificate email address (%s) does not match recipient's email address.\n",
	    certEmailAddr.getString());
	return;
	}

    // To send an encrypted email, only the public-key is required.

    // Use the certificate and indicate that the email should be encrypted.
    email.put_SendEncrypted(true);
    email.SetEncryptCert(&cert);

    // Use 3DES encryption.
    CkCSP csp;
    csp.SetProviderMicrosoftEnhanced();
    csp.SetEncryptAlgorithm("3DES");
    email.SetCSP(&csp);

    // Send the email
    if (!mailman.SendEmail(&email))
	{
	mailman.SaveLastError("errors.xml");
	}
    else
	{
	// The last error information will also contain information
	// about how the email was encrypted when successful, so you can
	// verify that what you expected to happen actually did happen.
	mailman.SaveLastError("info.xml");
	}


    }

************************
The info.xml file will look something like this:

<?xml version="1.0"  encoding="utf-8" standalone="yes" ?>
<ChilkatLog>
<SendEmail>
    <SMTP_Connect>
        <info>Connecting to SMTP server mail.earthlink.net:25</info>
        <smtp_host>mail.earthlink.net</smtp_host>
        <smtp_port>25</smtp_port>
        <smtp_user>NULL</smtp_user>
        <trying_auth_method>NONE</trying_auth_method>
        <login_method>NONE or already authenticated</login_method>
        <info>CONNECTED to ESMTP server mail.earthlink.net:25</info>
    </SMTP_Connect>
    <using_algorithm>3DES</using_algorithm>
    <info>Using explicit certificate.</info>
    <encryption_certificate>Thawte Freemail Member, support@chilkatsoft.com</encryption_certificate>
    <certificate_store></certificate_store>
    <logged_on_user>Matt Fausey</logged_on_user>
    <csp>Microsoft Enhanced Cryptographic Provider v1.0</csp>
    <alg_name>3DES</alg_name>
    <alg_bits>168</alg_bits>
    <encryptOid>1.2.840.113549.3.7</encryptOid>
    <subject>This is the email subject</subject>
    <from>matt@chilkatsoft.com</from>
    <recipients>
        <to>support@chilkatsoft.com</to>
    </recipients>
    <email_size>1622</email_size>
    <info>Mail sent to 1 recipient</info>
</SendEmail>
</ChilkatLog>

 

 

 

Need a specific example? Send a request to support@chilkatsoft.com

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

Mail Component · .NET Mail Component · XML Parser