Dart Smtp, Pop, Imap Controls
Imap Object
Members 
Description

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.

Object Model
Imap ObjectDartStrings CollectionICertificate ObjectMailboxes Collection
Remarks

The IMAP Control can:

Simple methods are provided to perform the following tasks:

 

Example
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
You want your mail transfer to operate in the background with minimal system impact. We recommend you program the mail transfer using non-blocking operation, so the user interface is not affected in any way. The following VB example shows how to retrieve a message when the user clicks a button:
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
For interactive applications, transparency is not as important and blocking operation may be acceptable as shown in the following VB example:
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
See Also

Imap Members


PowerTCP SSL for ActiveX Documentation Version 2.2.1
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic