VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
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...
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

 

 

 

 

 

 

Fetch Oldest/Newest IMAP Email

Emails may be downloaded by sequence number. Assuming the selected mailbox is not empty, the oldest email is at sequence number 1, and the newest email is at sequence number N. The FetchSingle method may be used to download by sequence number.

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

Dim imap As New Chilkat.Imap()

Dim success As Boolean

'  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


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


'  Login
success = imap.Login("***","***")
If (success <> true) Then
    MsgBox(imap.LastErrorText)
    Exit Sub
End If


'  Select an IMAP mailbox
success = imap.SelectMailbox("Inbox")
If (success <> true) Then
    MsgBox(imap.LastErrorText)
    Exit Sub
End If


'  After selecting a mailbox, the NumMessages property
'  contains the number of emails in the selected mailbox.
Dim n As Long
n = imap.NumMessages

If (n > 0) Then


    '  The oldest email is always at sequence number 1.
    Dim isUid As Boolean
    isUid = false

    Dim oldestEmail As Chilkat.Email
    oldestEmail = imap.FetchSingle(1,isUid)
    If (Not (oldestEmail Is Nothing )) Then

        '  Display the From and Subject
        TextBox1.Text = TextBox1.Text & oldestEmail.FromAddress & vbCrLf
        TextBox1.Text = TextBox1.Text & oldestEmail.Subject & vbCrLf

        TextBox1.Text = TextBox1.Text & "--" & vbCrLf

    End If


    '  The newest email is at sequence number N:
    Dim newestEmail As Chilkat.Email
    newestEmail = imap.FetchSingle(n,isUid)
    If (Not (newestEmail Is Nothing )) Then

        '  Display the From and Subject
        TextBox1.Text = TextBox1.Text & newestEmail.FromAddress & vbCrLf
        TextBox1.Text = TextBox1.Text & newestEmail.Subject & vbCrLf


    End If


End If


'  Disconnect from the IMAP server.
imap.Disconnect()
 

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

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

Mail Component · XML Parser