Visual Basic Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



VB Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Unicode
Upload
XML
XMP
Zip Compression

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor


VB Strings
VB Byte Array

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

S/MIME Explorer

Download Visual Basic Project Files and Source Code

ScreenShot

The S/MIME Explorer is a S/MIME example program that allows you to interactively build S/MIME messages using the Chilkat S/MIME component.

' This is a larger example that contains multiple source files.
' This listing is for the main form in the application.

Public g_getForSigning As Boolean
Public g_signCert As IChilkatCert
Public g_encryptCert As IChilkatCert
Public g_mime As ChilkatMime

Public Sub RefreshAll()
    Text1.Text = g_mime.GetMime()

    Charset.Text = g_mime.Charset
    ContentType.Text = g_mime.ContentType
    
    If (g_mime.IsApplicationData()) Then
        bcAppData.Caption = "App Data: YES"
        bcAppData.Font.Bold = True
    Else
        bcAppData.Caption = "App Data: NO"
        bcAppData.Font.Bold = False
    End If
    
    If (g_mime.IsText()) Then
        bcText.Caption = "Text: YES"
        bcText.Font.Bold = True
    Else
        bcText.Caption = "Text: NO"
        bcText.Font.Bold = False
    End If
    
    If (g_mime.IsImage()) Then
        bcImage.Caption = "Image: YES"
        bcImage.Font.Bold = True
        ShowImage.Enabled = True
    Else
        bcImage.Caption = "Image: NO"
        bcImage.Font.Bold = False
        ShowImage.Enabled = False
    End If
    
    If (g_mime.IsAudio()) Then
        bcAudio.Caption = "Audio: YES"
        bcAudio.Font.Bold = True
    Else
        bcAudio.Caption = "Audio: NO"
        bcAudio.Font.Bold = False
    End If
    
    If (g_mime.IsVideo()) Then
        bcVideo.Caption = "Video: YES"
        bcVideo.Font.Bold = True
    Else
        bcVideo.Caption = "Video: NO"
        bcVideo.Font.Bold = False
    End If
    
    If (g_mime.IsMultipart()) Then
        bcMultipart.Caption = "Multipart: YES"
        bcMultipart.Font.Bold = True
    Else
        bcMultipart.Caption = "Multipart: NO"
        bcMultipart.Font.Bold = False
    End If
    
    If (g_mime.IsPlainText()) Then
        ttPlain.Caption = "Plain: YES"
        ttPlain.Font.Bold = True
    Else
        ttPlain.Caption = "Plain: NO"
        ttPlain.Font.Bold = False
    End If
    
    If (g_mime.IsHtml()) Then
        ttHtml.Caption = "HTML: YES"
        ttHtml.Font.Bold = True
    Else
        ttHtml.Caption = "HTML: NO"
        ttHtml.Font.Bold = False
    End If
    
    If (g_mime.IsXml()) Then
        ttXml.Caption = "XML: YES"
        ttXml.Font.Bold = True
    Else
        ttXml.Caption = "XML: NO"
        ttXml.Font.Bold = False
    End If
    
    If (g_mime.IsSigned()) Then
        secSigned.Caption = "Signed: YES"
        secSigned.Font.Bold = True
    Else
        secSigned.Caption = "Signed: NO"
        secSigned.Font.Bold = False
    End If
    
    If (g_mime.IsEncrypted()) Then
        secEncrypted.Caption = "Encrypted: YES"
        secEncrypted.Font.Bold = True
    Else
        secEncrypted.Caption = "Encrypted: NO"
        secEncrypted.Font.Bold = False
    End If
    
    If (g_mime.IsMultipartMixed()) Then
        bcMMixed.Caption = "Mixed: YES"
        bcMMixed.Font.Bold = True
    Else
        bcMMixed.Caption = "Mixed: NO"
        bcMMixed.Font.Bold = False
    End If
    
    If (g_mime.IsMultipartRelated()) Then
        bcMRelated.Caption = "Related: YES"
        bcMRelated.Font.Bold = True
    Else
        bcMRelated.Caption = "Related: NO"
        bcMRelated.Font.Bold = False
    End If
    
    If (g_mime.IsMultipartAlternative()) Then
        bcMAlternative.Caption = "Alternative: YES"
        bcMAlternative.Font.Bold = True
    Else
        bcMAlternative.Caption = "Alternative: NO"
        bcMAlternative.Font.Bold = False
    End If
    
    If (g_mime.Encoding = "7bit") Then
        encSevenBit.Caption = "7bit: YES"
        encSevenBit.Font.Bold = True
    Else
        encSevenBit.Caption = "7bit: NO"
        encSevenBit.Font.Bold = False
    End If
    
    If (g_mime.Encoding = "8bit") Then
        encEightBit.Caption = "8bit: YES"
        encEightBit.Font.Bold = True
    Else
        encEightBit.Caption = "8bit: NO"
        encEightBit.Font.Bold = False
    End If
    
    If (g_mime.Encoding = "base64") Then
        encBase64.Caption = "Base 64: YES"
        encBase64.Font.Bold = True
    Else
        encBase64.Caption = "Base 64: NO"
        encBase64.Font.Bold = False
    End If
    
    If (g_mime.Encoding = "quoted-printable") Then
        encQP.Caption = "QuotedPrintable: YES"
        encQP.Font.Bold = True
    Else
        encQP.Caption = "QuotedPrintable: NO"
        encQP.Font.Bold = False
    End If
    
    If (g_mime.IsMultipart) Then
        SetBody.Enabled = False
    ElseIf (g_mime.IsText) Then
         SetBody.Enabled = True
    Else
        SetBody.Enabled = False
    End If
        
    
    If (g_mime.IsMultipart) Then
        Charset.Enabled = False
    Else
        Charset.Enabled = True
    End If
    
    Disposition.Text = g_mime.Disposition
    DispFile.Text = g_mime.Filename
    Encoding.Text = g_mime.Encoding
    
    Boundary.Text = g_mime.Boundary
    Protocol.Text = g_mime.Protocol
    CName.Text = g_mime.Name
    
    
End Sub

Private Sub AddDetachedSignature_Click()
    If (g_signCert Is Nothing) Then
        Status.Caption = "No signing certificate has been selected"
    Else
        g_mime.AddDetachedSignature g_signCert
        g_mime.SaveXmlLog "addDetachedLog.xml"
    End If
        
    RefreshAll
End Sub

Private Sub AddField_Click()
    g_mime.SetHeaderField FieldName.Text, FieldValue.Text
    RefreshAll
End Sub

Private Sub AddPart_Click()
    g_mime.AppendPartFromFile Filename2.Text
    RefreshAll
    
End Sub


Private Sub BrowsePart_Click()
    CommonDialog1.ShowOpen
    Filename2.Text = CommonDialog1.Filename

End Sub



Private Sub Browse_Click()
    CommonDialog1.ShowOpen
    Filename.Text = CommonDialog1.Filename
End Sub

Private Sub Command2_Click()
    
End Sub

Private Sub Encrypt_Click()
    If (g_encryptCert Is Nothing) Then
        Status.Caption = "No encryption certificate has been selected"
    Else
        g_mime.Encrypt g_encryptCert
    End If
    RefreshAll
End Sub

Private Sub Form_Load()
    SignCertLabel.Caption = "NONE"
    EncryptCertLabel.Caption = "NONE"
    Set g_mime = New ChilkatMime
    ' Edit the line below to provide the correct unlock code.
    g_mime.UnlockComponent UnlockCode.Text
    g_mime.SetBodyFromPlainText ("this is the body")
    RefreshAll
End Sub

Private Sub Generate_Click()
    Set g_mime = New ChilkatMime
    g_mime.SetBodyFromPlainText ("this is the body")
    RefreshAll
End Sub

Private Sub LoadBody_Click()
    g_mime.SetBodyFromFile (Filename2.Text)
    
        
    RefreshAll
End Sub

Private Sub LoadMime_Click()
    Dim failed As Long
    failed = g_mime.LoadMimeFile(Filename.Text)
    g_mime.SaveXmlLog "loadLog.xml"

    If (failed = 0) Then
        Status.Caption = "Loaded " + Filename.Text
    Else
        Status.Caption = "Cannot load " + Filename.Text
    End If
    
    RefreshAll
End Sub

Private Sub LoadXml_Click()
    Dim failed As Long
    failed = g_mime.LoadXmlFile(Filename.Text)
    If (failed = 0) Then
        Status.Caption = "Loaded " + Filename.Text
    Else
        Status.Caption = "Cannot load " + Filename.Text
    End If
    
    RefreshAll
End Sub


Private Sub MultipartAlternative_Click()
    If (OptMpart1.Value) Then
        g_mime.NewMultipartAlternative
    Else
        Dim m As ChilkatMime
        Set m = New ChilkatMime
        m.NewMultipartAlternative
        m.AppendPart g_mime
        Set g_mime = m
    End If
    RefreshAll
End Sub

Private Sub MultipartMixed_Click()
    If (OptMpart1.Value) Then
        g_mime.NewMultipartMixed
    Else
        Dim m As ChilkatMime
        Set m = New ChilkatMime
        m.NewMultipartMixed
        m.AppendPart g_mime
        Set g_mime = m
    End If
    
    RefreshAll
End Sub

Private Sub MultipartRelated_Click()
    If (OptMpart1.Value) Then
        g_mime.NewMultipartRelated
    Else
        Dim m As ChilkatMime
        Set m = New ChilkatMime
        m.NewMultipartRelated
        m.AppendPart g_mime
        Set g_mime = m
    End If
    
    RefreshAll
End Sub

Private Sub RemoveField_Click()
    g_mime.SetHeaderField FieldName.Text, " "
    RefreshAll
End Sub

Private Sub SaveMime_Click()
    g_mime.SaveMime Filename.Text
    Status.Caption = "Saved MIME:" & Filename.Text
End Sub

Private Sub SaveXml_Click()
    g_mime.SaveXml Filename.Text
    Status.Caption = "Saved XML:" & Filename.Text
    
End Sub

Private Sub SetBody_Click()
    Dialog.Show
End Sub

Private Sub SetEncryptCert_Click()
    g_getForSigning = False
    CertBrowser.Show
End Sub

Private Sub SetSigningCert_Click()
    g_getForSigning = True
    CertBrowser.Show
End Sub

Private Sub ShowImage_Click()
    If (g_mime.IsImage()) Then
        fname = "tmp_" & g_mime.Filename
        g_mime.SaveBody fname
        DisplayImage.Picture1 = LoadPicture(fname)
        DisplayImage.Show
    End If

End Sub

Private Sub SignMessage_Click()
    If (g_signCert Is Nothing) Then
        Status.Caption = "No signing certificate has been selected"
    Else
        g_mime.ConvertToSigned g_signCert
        g_mime.SaveXmlLog "convertToSignedLog.xml"
    End If
    RefreshAll
End Sub

Private Sub UnwrapSecurity_Click()
    success = g_mime.UnwrapSecurity
    RefreshAll
End Sub

Private Sub UpdateDisp_Click()
    g_mime.Disposition = Disposition.Text
    g_mime.Filename = DispFile.Text
    g_mime.Encoding = Encoding.Text
    RefreshAll
    
End Sub

Private Sub UpdateHeader_Click()
    g_mime.Charset = Charset.Text
    g_mime.ContentType = ContentType.Text
    g_mime.Boundary = Boundary.Text
    g_mime.Name = CName.Text
    g_mime.Protocol = Protocol.Text
    RefreshAll
End Sub

Private Sub ViewCerts_Click()
    ViewCertsDlg.Show
End Sub

 

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

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