Sample code for 30+ languages & platforms
Visual Basic 6.0

Connecting to GMAIL using IMAP

Demonstrates how to connect to GMAIL using IMAP.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

Dim imap As New ChilkatImap

' Turn on session logging:
imap.KeepSessionLog = 1

' Connect to GMail
' Use TLS
imap.Ssl = 1
imap.Port = 993
success = imap.Connect("imap.gmail.com")
If (success <> 1) Then
    Debug.Print imap.LastErrorText
    Exit Sub
End If

' Login
' Your login is typically your GMail email address.
success = imap.Login("username@gmail.com","myPassword")
If (success <> 1) Then
    Debug.Print imap.LastErrorText
    Exit Sub
End If

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

' Show the session log.
Debug.Print imap.SessionLog

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