VB.NET Examples

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

VB.NET Examples

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

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

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

Encrypting and Decrypting MIME

Download Chilkat .NET for 4.0 Framework

Download Chilkat .NET for 64-bit 4.0 Framework (x64)

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 64-bit 2.0 / 3.5 Framework (x64)

Download Chilkat .NET for 1.0 / 1.1 Framework

Example code showing how to encrypt and decrypt MIME.

        Dim success As Boolean

        ' Create S/MIME encrypted MIME and decrypt using a digital certificate.
        Dim mime As New Chilkat.Mime()
        mime.UnlockComponent("anything for 30-day trial")

        ' Create a simple MIME message with 2 header fields and a plain-text body.
        mime.AddHeaderField("field1", "value1")
        mime.AddHeaderField("field2", "value2")
        mime.SetBodyFromPlainText("This is a plain-text body")

        TextBox1.Text = mime.GetMime()
        ' The text box will display this:
        ' field1: value1
        ' field2: value2
        ' content-type: text/plain;
        '         charset = "us-ascii"
        ' content-transfer-encoding: 7bit
        ' 
        ' This is a plain-text body

        ' Load a certificate from a .cer file.
        Dim cert As New Chilkat.Cert()
        success = cert.LoadFromFile("tagtooga.cer")
        If (Not success) Then
            MsgBox(cert.LastErrorText)
            Exit Sub
        End If

        success = mime.Encrypt(cert)
        If (Not success) Then
            MsgBox(mime.LastErrorText)
            Exit Sub
        End If

        ' Show the encrypted MIME
        TextBox2.Text = mime.GetMime()

        ' The text box will display this:
        ' field1: value1
        ' field2: value2
        ' content-disposition: attachment;
        '         filename = "smime.p7m"
        '         content-transfer-encoding : base64
        ' content-type: application/x-pkcs7-mime;
        '         Name = "smime.p7m"
        ' 
        '         MIIB5wYJKoZIhvcNAQcDoIIB2DCCAdQCAQAxggERMIIBDQIBADB2MGIxCzAJBgNVBAYTAlpB
        ' (The remainder of the MIME is nothing more than base64 data...)

        ' To decrypt:
        success = mime.UnwrapSecurity()
        If (Not success) Then
            MsgBox(mime.LastErrorText)
            Exit Sub
        End If

        TextBox3.Text = mime.GetMime()
        ' The result is this:
        ' field1: value1
        ' field2: value2
        ' content-type: text/plain;
        '         charset = "us-ascii"
        ' content-transfer-encoding: 7bit
        ' X-NumPartsEncrypted: 1
        ' X-Decrypted : yes
        ' 
        ' This is a plain-text body

        ' If we do not want the X-NumPartsEncrypted and X-Decrypted fields added,
        ' set mime.UnwrapExtras = false
        Dim mime2 As New Chilkat.Mime()
        mime2.UnwrapExtras = False
        mime2.AddHeaderField("field1", "value1")
        mime2.AddHeaderField("field2", "value2")
        mime2.SetBodyFromPlainText("This is a plain-text body")
        mime2.Encrypt(cert)
        mime2.UnwrapSecurity()
        TextBox3.Text = mime2.GetMime()
        ' We now have the original MIME...




 

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

Mail Component · XML Parser