Programming Examples

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

C Examples

Bounced Mail
Bz2
Certificates/Keys
Charset
CSV
DKIM / DomainKey
Diffie-Hellman
DSA
Email Object
Encryption
FileAccess
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
MIME
NTLM
POP3
RSA
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
Zip
Amazon S3

 

 

 

 

 

 

 

 

Send S/MIME Encrypted Email

Send encrypted email using the digital certificate of the recipient. To successfully encrypt, the recipient's certificate must be installed or available from a .cer file or elsewhere (such as LDAP, a database, etc.). Only the public key is required to encrypt an email. The private key is not necessary. (The private key is necessary for decryption. Thus, when an encrypted email is sent, only the recipient may decrypt because only the recipient holds the private key.)

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
#include <C_CkMailMan.h>
#include <C_CkEmail.h>

void ChilkatSample(void)
    {
    HCkMailMan mailman;
    BOOL success;
    HCkEmail email;

    //  The mailman object is used for sending and receiving email.
    mailman = CkMailMan_Create();

    //  Any string argument automatically begins the 30-day trial.

    success = CkMailMan_UnlockComponent(mailman,"30-day trial");
    if (success != TRUE) {
        printf("Component unlock failed\n");
        return;
    }

    //  Set the SMTP server.
    CkMailMan_putSmtpHost(mailman,"smtp.comcast.net");

    //  Create a new email object
    email = CkEmail_Create();

    CkEmail_putSubject(email,"This email is encrypted");
    CkEmail_putBody(email,"This is a digitally encrypted mail");
    CkEmail_putFrom(email,"Chilkat Support <support@chilkatsoft.com>");
    CkEmail_AddTo(email,"Test Email","test@testemail.net");

    //  In this example, we've already installed the certificate for "test@testemail.net"
    //  in the current user's personal certificate store.
    //  If the email.SendEncrypted property is set, Chilkat will
    //  automatically search for and use the first non-expired certificate
    //  matching the recipient's email address.  Chilkat searches
    //  the Current User's Personal certificate store, as well
    //  as the Local Machine's Personal certificate store.
    //  Run certmgr.msc to view the certs in the Current User's
    //  certificate store.
    CkEmail_putSendEncrypted(email,TRUE);

    success = CkMailMan_SendEmail(mailman,email);
    if (success != TRUE) {
        printf("%s\n",CkMailMan_lastErrorText(mailman));
    }
    else {
        printf("Mail Sent!\n");
    }


    CkMailMan_Dispose(mailman);
    CkEmail_Dispose(email);

    }

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

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