Search Method
Searches the currently selected mailbox for
messages which meet specified condition.
Message numbers (or UIDs) are returned as array of numbers. Lower bound of the
array is 1.
By default, this method just returns message numbers or UIDs for all messages
in the mailbox. To search for specific items, specify non-empty search Condition.
Condition is a set of search criteria in IMAP4 format. Some popular search
keys are listed below:
| arrIndices = ObjectName.Search(AsUID, [Condition], [Charset]) | ||
| Parameters: | ||
| AsUID As Boolean | If True, returned array will be array of UIDs (unique-IDs). Otherwise, message numbers will be returned | |
| Condition As String | (optional) Search condition. Default is "ALL" (all messages in the currently selected mailbox returned) | |
| Charset as String | (optional) Charset of the string that appear in search criteria. If not specified, default (US-ASCII) charset is assumed | |
| Return value As Variant | Array of Variant/Long, each value is UID or message number of the message. If error has occurred, return value is Empty | |
Usage example:
' This sample searches Inbox and retrieves recent messages only Dim Mailer, SearchResults, Message, I 'Using visual basic to create object Set Mailer = CreateObject("MailBee.IMAP4") 'Using ASP to create object 'Set Mailer = Server.CreateObject("MailBee.IMAP4") 'In ASP use Response.Write instead of MsgBox Mailer.EnableLogging = True Mailer.LogFilePath = "C:\imap4_log.txt" Mailer.ClearLog Mailer.LicenseKey = "put your license key here" If Mailer.Connect("mailserver.com", 143, "MyName", "MyPassword") Then If Mailer.SelectMailbox("Inbox") Then SearchResults = Mailer.Search(False, "RECENT") ' Get list of message numbers of recent messages If Not IsEmpty(SearchResults) Then For I = LBound(SearchResults) To UBound(SearchResults) Set Message = Mailer.RetrieveSingleMessage(SearchResults(I), False) If Not Message Is Nothing Then MsgBox Message.BodyText End If Next End If End If Mailer.Disconnect End If
See Also:
Envelope.UID
Property
RetrieveEnvelopes Method
RetrieveEnvelopesEx Method
RetrieveSingleMessage Method
Copyright 2002-2008, AfterLogic Corporation. All rights reserved.