Visual Basic Examples

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

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

S/MIME Decrypt

Download Chilkat MIME ActiveX

This Visual Basic sample program shows how to decrypt an x-pkcs7-mime MIME message. The attached content of the unencrypted message (a GIF image in this case) is then saved to a file.

' Loads an encrypted MIME message, unwraps the security envelopes, and determines
' if the decryption was successful.
Private Sub Command1_Click()

        Dim mime As New ChilkatMime

        
        mime.UnlockComponent "Anything for 30-day trial"
        mime.LoadMimeFile "encrypted.txt"

        ' Determine if this is an encrypted message or not.
        If (mime.IsEncrypted() = 1) Then
            ListBox1.AddItem "Message is encrypted"
        Else
            ListBox1.AddItem "Message is not encrypted"
        End If

        ' Unwrap the security.
        ' The results are stored within the Mime object and can be queried
        ' afterwards.
        ' The UnwrapSecurity does all decryption and signature validation,
        ' regardless of how complex the MIME message may be.
        Dim decryptSuccess As Long
        decryptSuccess = mime.UnwrapSecurity()
        If (decryptSuccess = 1) Then
            ListBox1.AddItem "Message has been decrypted"
        Else
            ListBox1.AddItem "Message not decrypted"
        End If

        ' Save the decrypted MIME message.
        mime.SaveMime "decrypted.txt"
        ' (You can convert any MIME message to XML too.)
        mime.SaveXml "decrypted.xml"

        ' Get the first encrypting certificate.
        ' In complex cases where the MIME is nested and contains
        ' other encrypted MIME messages, there will be more than
        ' one encrypting certificate.
        Dim cert As ChilkatCert
        Set cert = mime.GetEncryptCert(0)
        ListBox1.AddItem "Encrypted By: " + cert.SubjectDN

        ' This example uses a MIME message that included a GIF attachment.
        ' Save the GIF to a file.
        Dim gifAttachment As ChilkatMime
        Set gifAttachment = mime.GetPart(1)
        gifAttachment.SaveBody "dude.gif"

End Sub






 

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