Use the IMAP Control to retrieve mail from or store mail to any IMAP server. Mailboxes on the server are exposed as a collection of Mailbox Objects. Each Mailbox Object contains messages that can be retrieved and stored in its Messages property.
Powerful default operations are provided, including iteration through a message set to populate the Messages property.
The IMAP Control can:
Simple methods are provided to perform the following tasks:
Private Sub Command1_Click() On Error GoTo OnError ' use intrinsic error handling ' default timeout implies blocking operation Imap1.Login "imap.server.com", "user", "pass" ' Get all mailboxes Imap1.Refresh ' Imap1.Mailboxes("INBOX").Count now contains the number of messages in the INBOX ' Get messages and put them into the Imap1.Mailboxes("INBOX").Messages ' collection Imap1.Mailboxes("INBOX").Get Imap1.Mailboxes("INBOX").Refresh Text1.Text = Imap1.Mailboxes("INBOX").Count Exit Sub OnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description End Sub
Private Sub Command1_Click() ' use non-blocking operation Imap1.Timeout = 0 ' login to our server Imap1.Login "imap.test.com", "user", "pass" ' pick this operation up in the Progress event End Sub Private Sub Imap1_Progress(ByVal Method As DartMailCtl.ImapMethodConstants, ByVal Status As DartMailCtl.ImapStatusConstants, ByVal Reply As String, ByVal MessageNumber As Long, ByVal Count As Long, ByVal Size As Long) If Status = imapOk Then Select Case Method Case imapLogin ' logged in, get mailboxes Imap1.Refresh Case imapMailboxesRefresh ' mailbox listing complete, get INBOX messages Imap1.Mailboxes("INBOX").Get Case imapGet ' mail retrieve is complete for INBOX, log out Imap1.Logout Case imapLogout ' operation complete End Select End If End Sub
Private Sub Command1_Click() On Error Goto OnError ' use intrinsic error handling ' Use the Timeout property to establish blocking operation Imap1.Timeout = 1000 ' Specify the address of the server to connect to Imap1.Login "imap.test.com", "user", "pass" 'Get Mailbox listing Imap1.Refresh ' get all the messages from INBOX and put them in the messages property Imap1.Mailboxes("INBOX").Get ' all done, close connection!! Imap1.Logout Exit Sub OnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description End Sub