Chilkat Examples

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

Classic ASP 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
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
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
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

Read S/MIME Encrypted Email

Read S/MIME encrypted email.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set imap = Server.CreateObject("Chilkat_9_5_0.Imap")

'  Anything unlocks the component and begins a fully-functional 30-day trial.
success = imap.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    Response.Write imap.LastErrorText & "<br>"

End If

'  Connect to an IMAP server.
success = imap.Connect("mail.chilkatsoft.com")
If (success <> 1) Then
    Response.Write imap.LastErrorText & "<br>"

End If

'  Login
success = imap.Login("myLogin","myPassword")
If (success <> 1) Then
    Response.Write imap.LastErrorText & "<br>"

End If

'  Select an IMAP mailbox
success = imap.SelectMailbox("Inbox")
If (success <> 1) Then
    Response.Write imap.LastErrorText & "<br>"

End If

'  The AutoUnwrapSecurity method controls whether signed/encrypted emails are automatically
'  decrypted and/or verified.

'  When set to 1, which is the default, security envelopes are automatically "unwrapped"
'  when a message is retrieved from the server. Signed emails are automatically verified, and
'  encrypted emails are automatically decrypted, restoring the email to the original state before
'  signing and/or encrypting. Information about the signing and encrypting certificates can be
'  retrieved from the Email object (methods: GetSignedByCert, GetEncryptedByCert;
'  properties: SignedBy, EncryptedBy, SignaturesValid, Decrypted, ReceivedSigned,
'  ReceivedEncrypted).

'  This example will explicity set AutoUnwrapSecurity to 1, even though it's
'  already the default value:
imap.AutoUnwrapSecurity = 1

'  The NumMessages property contains the number of messages in the selected mailbox.
numToFetch = imap.NumMessages
'  Download all the email in the Inbox.

Set bundle = imap.FetchSequence(1,numToFetch)
If (bundle Is Nothing ) Then
    Response.Write imap.LastErrorText & "<br>"

End If

'  Loop over the bundle,

For i = 0 To bundle.MessageCount - 1

    Set email = bundle.GetEmail(i)

    Response.Write Server.HTMLEncode( email.From) & "<br>"
    Response.Write Server.HTMLEncode( email.Subject) & "<br>"

    '  At this point, if the email was signed and/or encrypted, it is already "unwrapped", i.e.
    '  the email is already decrypted and in a state as if it were never signed or encrypted.
    '  You may check to see if the email was received encrypted or signed, and if so,
    '  whether it was successfully unwrapped and who signed or encrypted it:
    If (email.ReceivedEncrypted = 1) Then

        Response.Write Server.HTMLEncode( "This email was encrypted when received.") & "<br>"
        If (email.Decrypted = 1) Then
            Response.Write Server.HTMLEncode( "This email was successfully decrypted.  It was encrypted by:") & "<br>"
            Response.Write Server.HTMLEncode( email.EncryptedBy) & "<br>"
        Else
            Response.Write Server.HTMLEncode( "This email was not decrypted.") & "<br>"
        End If

    End If

    If (email.ReceivedSigned = 1) Then

        Response.Write Server.HTMLEncode( "This email was signed when received.") & "<br>"
        If (email.SignaturesValid = 1) Then
            Response.Write Server.HTMLEncode( "The signature was verified.  It was signed by:") & "<br>"
            Response.Write Server.HTMLEncode( email.SignedBy) & "<br>"
        Else
            Response.Write Server.HTMLEncode( "The signature verification failed.") & "<br>"
        End If

    End If

    '  The email's body, HTML body, attachments, etc.
    '  are decrypted and available just like any non-encrypted email.

    Response.Write Server.HTMLEncode( "--") & "<br>"

Next

'  Disconnect from the IMAP server.
imap.Disconnect 


%>
</body>
</html>

 

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