The SearchMailbox method is used to search a mailbox for
messages which match a given criteria and return a list of the
matching message numbers. The search criteria is composed of one or
more search keywords and and optional value to match against. String
searches are not case sensitive and partial matches in the message
are returned. The message numbers returned by this method are only
valid until the mailbox is expunged or another mailbox is
selected.
In addition to the listed keywords, the keyword NOT may prefix a
keyword to return those messages which do not match the search
criteria. For example, "NOT TO user@domain.com" would
return those messages which were not addressed to
user@domain.com.
If multiple search keywords are specified, the result is the
intersection of all those messages which meet the search criteria.
For example, a search criteria of "DELETED SINCE
1-Jan-2010" would return all those messages which are marked
for deletion and were added to the mailbox after 1 January
2010.
Those search keywords which expect dates must be specified in
format dd-mmm-yyyy where the month is the three letter
abbreviation for the month name. Note that the internal date the
message was added to the mailbox is not the same as the value of
the Date header field in the message.
If the search keyword expects a string value and the string
contains one or more spaces, you need to enclose the search string
in quotes as part of the criteria string. For example, in Visual
Basic you could use code like this:
strCriteria = "SUBJECT " + Chr(34) + "search string" + Chr(34)
The quotes around the search string prevents the server from
interpreting it as a multiple search criteria to be evaluated. If
you are using a search string provided by a user, it is recommended
that you always enclose it in quotes to prevent any potential
ambiguity in the search. Even if the search string does not contain
any spaces, it is always safe to enclose it in quotes.
The UID keyword expects a one or more unique message
identifiers. These values may provided as comma separated list, or
a range delimited by a colon. For example, "UID
23000:24000" would return all those messages who have UIDs
ranging from 23000 through to 24000.