VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



VB.NET Examples

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

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

Byte Array
VB.NET FTPS
System.IO

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

 

 

 

 

 

 

Read Email Headers and List Attachments

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
        imap.UnlockComponent("30-day trial")

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

        ' Connect to the IMAP server.
        imap.Connect("mail.chilkatsoft.com")

        ' 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)

        ' Fetch email headers into a bundle object.
        Dim bundle As New Chilkat.EmailBundle
        bundle = imap.FetchHeaders(msgSet)

        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




 

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

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

Mail Component · XML Parser