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

 

 

 

 

 

 

Read Email Headers and List Attachments

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

VB.NET example program showing how to read a headers from a mailbox on an IMAP server and list attachment information.

' Read email headers from IMAP mailbox and show attachment
' filenames and sizes.
Dim imap As New Chilkat.Imap

'  Anything unlocks the component and begins a fully-functional 30-day trial.
success = imap.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
    MsgBox(imap.LastErrorText)
    Exit Sub
End If


' If SSL is required, set the Port and Ssl properties:
'imap.Port = 993
'imap.Ssl = True

'  Connect to an IMAP server.
success = imap.Connect("mail.chilkatsoft.com")
If (success <> true) Then
    MsgBox(imap.LastErrorText)
    Exit Sub
End If


' Login
If Not (imap.Login("myLogin", "myPassword")) Then
    MessageBox.Show(imap.LastErrorText)
    Exit Sub
End If

' Select a mailbox
If (Not imap.SelectMailbox("Inbox")) Then
    MessageBox.Show(imap.LastErrorText)
    Exit Sub
End If

' Get ALL messages.
Dim msgSet As Chilkat.MessageSet
msgSet = imap.Search("ALL", True)
If (msgSet Is Nothing ) Then
    MsgBox(imap.LastErrorText)
    Exit Sub
End If

' Fetch email headers into a bundle object.
Dim bundle As New Chilkat.EmailBundle
bundle = imap.FetchHeaders(msgSet)
If (bundle Is Nothing ) Then
    MsgBox(imap.LastErrorText)
    Exit Sub
End If

Dim email As Chilkat.Email

Dim i As Long
For i = 0 To bundle.MessageCount - 1

    email = bundle.GetEmail(i)

    ListBox1.Items.Add("-")
    ListBox1.Items.Add(email.Subject)

    ' We cannot use the email.NumAttachments property
    ' because we only fetched the headers.  For this, we must
    ' use the Chilkat.Imap methods that fetch attachment information
    ' from downloaded headers.  The GetMailNumAttach, GetMailAttachFilename,
    ' and GetMailAttachSize methods do not communicate with the IMAP server.
    ' Rather, they extract the attachment information that was provided
    ' by the IMAP server when the headers were downloaded.

    Dim numAttach As Long
    numAttach = imap.GetMailNumAttach(email)

    ListBox1.Items.Add("number of attachments = " + Str(numAttach))

    If (imap.GetMailNumAttach(email) > 0) Then
        Dim j As Long
        For j = 0 To numAttach - 1
            ListBox1.Items.Add("    " + imap.GetMailAttachFilename(email, j) + _
                ", size = " + Str(imap.GetMailAttachSize(email, j)))
        Next
    End If

Next


 

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

Mail Component · XML Parser