Visual Basic Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB Examples

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

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


VB Strings
VB Byte Array

 

 

 

 

 

 

 

Read Signed Email

Download Chilkat Email ActiveX

This example demonstrates how to read digitally signed email in VB6.


' Demonstrates how to read digitally signed email in VB6
Private Sub Command1_Click()

    ' Create the mailman object for receiving email
    Dim mailman As ChilkatMailMan2
    Set mailman = New ChilkatMailMan2
    
    ' Unlock the component - any string will begin the 30-day trial.
    mailman.UnlockComponent UnlockCode.Text

    ' Set our POP3 hostname, login, password
    mailman.MailHost = PopHost.Text
    mailman.PopUsername = PopLogin.Text
    mailman.PopPassword = PopPassword.Text
    
    ' How many messages are on the POP3 server?
    Dim messageCount
    messageCount = mailman.CheckMail
    LogWindow.Text = messageCount & " messages waiting on server" & vbCrLf
    
    
    ' Copy email from the POP3 server into an email bundle.
    ' Use mailman.TransferMail to move email off the POP3 server.
    Dim bundle As ChilkatEmailBundle2
    Set bundle = mailman.CopyMail
    
    ' You can save the bundle as XML if desired.
    bundle.SaveXML "bundle.xml"
        
    ' Loop over each message in the bundle
    messageCount = bundle.messageCount
    Dim i As Long
    Dim email As ChilkatEmail2
    For i = 0 To messageCount - 1
    
        Set email = bundle.GetEmail(i)
        
        ' When Chilkat Mail reads mail, it automatically "unwraps" the security.
        ' If an email is signed, it verifies the signature and stores the information
        ' about the identity of the signer and the signature validity within the email object.
        ' The email object is returned to you as it was just before being signed.
        ' The ReceivedSigned property is set to 1 if the email was signed, otherwise it is 0.
        LogWindow.Text = LogWindow.Text & "message " & i & vbCrLf
        LogWindow.Text = LogWindow.Text & "RECEIVED SIGNED? " & Str(email.ReceivedSigned) & vbCrLf
        If (email.ReceivedSigned = 1) Then
        
            LogWindow.Text = LogWindow.Text & "SIGNED BY: " & email.SignedBy & vbCrLf
            LogWindow.Text = LogWindow.Text & "SIGNATURE VALID: " & Str(email.SignaturesValid) & vbCrLf
            
            ' The digital certificate can be retrieved by calling GetSignedByCert.
            Dim cert As ChilkatCert
            Set cert = email.GetSignedByCert()
            If (Not (cert Is Nothing)) Then
                LogWindow.Text = LogWindow.Text & "CERT SERIAL NUMBER: " & cert.SerialNumber & vbCrLf
            End If
            
        End If
        
        
        ' Print some information from the email.
        LogWindow.Text = LogWindow.Text & "from: " & email.From & vbCrLf
        LogWindow.Text = LogWindow.Text & "subject: " & email.Subject & vbCrLf
        LogWindow.Text = LogWindow.Text & "Local Date: " & email.LocalDate & vbCrLf
        
        ' Print the recipients.
        Dim j As Long
        For j = 0 To email.NumTo - 1
            LogWindow.Text = LogWindow.Text & "to: " & email.GetTo(j) & vbCrLf
        Next
        For j = 0 To email.NumCC - 1
            LogWindow.Text = LogWindow.Text & "cc: " & email.GetCC(j) & vbCrLf
        Next
                
        ' Now print the default email body.
        LogWindow.Text = LogWindow.Text & "Body: " & email.Body & vbCrLf
        
        Set email = Nothing
        
        LogWindow.Text = LogWindow.Text & "----" & vbCrLf
        
    Next
    
    mailman.SaveLastError "log.xml"
    
    Set mailman = Nothing
    
End Sub



 

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

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