Find Method

Applies To

Items collection object, UserProperties collection object.

Description

Items object: Applies the filter to the Items collection and returns the first Item object matching the filter.

UserProperties object: Locates and returns a UserProperty object for the requested property name, if it exists.

Syntax 1

expression.Find(Filter)

Syntax 2

expression.Find(Name, Custom)

expression An expression that returns an Items object (Syntax 1) or a UserProperties object (Syntax 2).

Filter Required String. An expression that will evaluate to True or False.

The filter is a string expression containing one or more filter clauses joined by the logical operators And, Not and Or.

A filter clause is a simple expression that evaluates to True or False; for example, [CompanyName] = "Microsoft".

Note that property names can be used in the expression and are identified and delimited by square brackets. Except for these bracketed property names, only literals are allowed within the expression — variables and constants are not evaluated.

Comparison operators allowed within the filter expression include >, <, >=, <=, = and <>.

Logical operators allowed are And, Not and Or.

Name Required String. The display name of the requested property.

Custom Optional Boolean. True if the requested property is a user (custom) property. False if it is a system property. The default value is True.

Remarks

For the UserProperties object, Find cannot be used, and will cause an error, with the following properties:

  • ConversationIndex
  • Email1EntryID
  • Email2EntryID
  • Email3EntryID
  • EntryID
  • ReceivedByEntryID
  • ReceivedOnBehalfOfEntryID
  • ResponseState
  • Saved
  • Unread
  • UserCertificate
  • VotingOptions

See Also

FindNext method, Restrict method.

Example

This example opens the default Calendar folder and finds the first appointment whose subject is "Golf w/ Jerry Wheeler."

Set myCalendar = olNameSpace.GetDefaultFolder (olFolderCalendar)
Set myItem = myCalendar.Items.Find _
    ("[Subject] = ""Golf w/ Jerry Wheeler""")
This example opens the default Contacts folder and finds the first contact filed as "Jones" whose first name is "Brent."

Set myContacts = olNameSpace.GetDefaultFolder (olFolderContacts)
Set myItem = myContacts.Items.Find _
    ("[FileAs] = ""Jones"" and [FirstName] = ""Brent""")
This example finds a custom property named "LastDateContacted" for the contact.

Set myProperty = _
    myContact.UserProperties.Find("LastDateContacted")
MsgBox "Last Date Contacted: " & myProperty.Value