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

 

 

 

 

 

 

 

 

POP3 Verify Signed (S/MIME) Email

Demonstrates how to download and verify digitally signed S/MIME email.

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
FreeBSD C++ Libraries
HP-UX C++ Libraries
BlackBerry QNX C++ Libraries
#include <C_CkMailMan.h>
#include <C_CkStringArray.h>
#include <C_CkEmail.h>
#include <C_CkCert.h>

void ChilkatSample(void)
    {
    HCkMailMan mailman;
    BOOL success;
    HCkStringArray sa;
    long i;
    long n;
    HCkEmail email;
    const char * uidl;
    HCkCert cert;

    mailman = CkMailMan_Create();

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

    success = CkMailMan_UnlockComponent(mailman,"30-day trial");
    if (success != TRUE) {
        printf("%s\n",CkMailMan_lastErrorText(mailman));
        return;
    }

    //  Set the POP3 server's hostname
    CkMailMan_putMailHost(mailman,"mail.chilkatsoft.com");

    //  Set the POP3 login/password.
    CkMailMan_putPopUsername(mailman,"myLogin");
    CkMailMan_putPopPassword(mailman,"myPassword");

    sa = CkMailMan_GetUidls(mailman);
    if (sa == 0 ) {
        printf("%s\n",CkMailMan_lastErrorText(mailman));
        return;
    }

    n = CkStringArray_getCount(sa);

    for (i = 0; i <= n - 1; i++) {

        uidl = CkStringArray_getString(sa,i);

        email = CkMailMan_FetchEmail(mailman,uidl);
        if (email == 0 ) {
            printf("%s\n",CkMailMan_lastErrorText(mailman));
            break;
        }

        printf("%s\n",CkEmail_ck_from(email));
        printf("%s\n",CkEmail_subject(email));

        //  The security layers of signed and/or encrypted emails
        //  are automatically "unwrapped" when loaded into
        //  a Chilkat email object.
        //  An application only needs to check to see if an email
        //  was received signed or encrypted, and then examine
        //  the success/failure.  For example:
        if (CkEmail_getReceivedSigned(email) == TRUE) {

            printf("This email was signed.\n");

            //  Check to see if the signatures were verified.
            if (CkEmail_getSignaturesValid(email) == TRUE) {
                printf("Digital signature(s) verified.\n");

                printf("Signer: %s\n",CkEmail_signedBy(email));

                //  The certificate used for signing may be obtained
                //  by calling email.GetSignedByCert.

                cert = CkEmail_GetSignedByCert(email);
                if (cert == 0 ) {
                    printf("Failed to get signing certificate object.\n");
                }
                else {
                    printf("Signing cert: %s\n"
                        ,CkCert_subjectCN(cert));
                    CkCert_Dispose(cert);
                }

            }
            else {
                printf("Digital signature verification failed.\n");
            }

        }

        CkEmail_Dispose(email);
    }

    CkStringArray_Dispose(sa);

    CkMailMan_Pop3EndSession(mailman);

    CkMailMan_Dispose(mailman);

    }

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

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