Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

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


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

 

Create S/MIME Detached Signature with PFX

How to use a PFX to create a signed S/MIME message.

Download Chilkat C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C++ Libraries for VC++ 6.0 / Win32

#include <CkMime.h>
#include <CkCertStore.h>
#include <CkString.h>
#include <CkCert.h>

void ChilkatSample(void)
    {

    CkMime mime;

    bool success;
    success = mime.UnlockComponent("Anything for 30-day trial");
    if (success == false) {
        printf("Failed to unlock component\n");
        return;
    }

    mime.AddHeaderField("Subject","This is a test");
    mime.AddHeaderField("Abc","123");

    mime.SetBodyFromPlainText("This is the body");

    CkCertStore certStore;

    CkString password;
    password = "myPassword";
    success = certStore.LoadPfxFile("chilkat.pfx",password);
    if (success == false) {
        printf("%s\n",certStore.lastErrorText());
        return;
    }

    CkCert *cert = 0;
    cert = certStore.FindCertBySubjectCN("Chilkat Software, Inc.");
    if (cert == 0 ) {
        printf("Failed to find certificate!\n");
        return;
    }

    //  Display the full distinguished name of the cert.
    printf("%s\n",cert->subjectDN());

    success = mime.AddDetachedSignature(*cert);
    if (success == false) {
        printf("%s\n",mime.lastErrorText());
        return;
    }

    delete cert;

    printf("%s\n",mime.getMime());


    }

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