Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples
Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) POP3 Verify Signed (S/MIME) Email

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

Note: This example requires Chilkat v11.0.0 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoMailman
    Variant vStUidls
    Handle hoStUidls
    Variant vEmail
    Handle hoEmail
    Variant vCert
    Handle hoCert
    Integer iCount
    Integer i
    String sTemp1
    Boolean bTemp1

    Move False To iSuccess

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatMailMan)) To hoMailman
    If (Not(IsComObjectCreated(hoMailman))) Begin
        Send CreateComObject of hoMailman
    End

    // Set the POP3 server's hostname
    Set ComMailHost Of hoMailman To "pop.example.com"

    // Set the POP3 login/password.
    Set ComPopUsername Of hoMailman To "myLogin"
    Set ComPopPassword Of hoMailman To "myPassword"

    Get Create (RefClass(cComChilkatStringTable)) To hoStUidls
    If (Not(IsComObjectCreated(hoStUidls))) Begin
        Send CreateComObject of hoStUidls
    End
    Get pvComObject of hoStUidls to vStUidls
    Get ComFetchUidls Of hoMailman vStUidls To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End
    Get Create (RefClass(cComChilkatCert)) To hoCert
    If (Not(IsComObjectCreated(hoCert))) Begin
        Send CreateComObject of hoCert
    End

    Get ComCount Of hoStUidls To iCount
    Move 0 To i
    While (i < iCount)
        // Download the full email.
        Get ComStringAt Of hoStUidls i To sTemp1
        Get pvComObject of hoEmail to vEmail
        Get ComFetchByUidl Of hoMailman sTemp1 False 0 vEmail To iSuccess
        If (iSuccess = False) Begin
            Get ComLastErrorText Of hoMailman To sTemp1
            Showln sTemp1
            Procedure_Return
        End

        Showln i
        Get ComFrom Of hoEmail To sTemp1
        Showln "From: " sTemp1
        Get ComSubject Of hoEmail To sTemp1
        Showln "Subject: " sTemp1

        // 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:
        Get ComReceivedSigned Of hoEmail To bTemp1
        If (bTemp1 = True) Begin

            Showln "This email was signed."

            // Check to see if the signatures were verified.
            Get ComSignaturesValid Of hoEmail To bTemp1
            If (bTemp1 = True) Begin
                Showln "Digital signature(s) verified."
                Get ComSignedBy Of hoEmail To sTemp1
                Showln "Signer: " sTemp1

                Get pvComObject of hoCert to vCert
                Get ComLastSignerCert Of hoEmail 0 vCert To iSuccess
                If (iSuccess = False) Begin
                    Get ComLastErrorText Of hoEmail To sTemp1
                    Showln sTemp1
                    Procedure_Return
                End

                Get ComSubjectCN Of hoCert To sTemp1
                Showln "Signing cert: " sTemp1
            End

        End
        Else Begin
            Showln "Digital signature verification failed."
        End

        Move (i + 1) To i
    Loop

    Get ComPop3EndSession Of hoMailman To iSuccess


End_Procedure

 

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