Find Method Example

This Visual Basic for Applications example opens the default Calendar folder and uses the Find method to find the first appointment whose subject is "Golf w/ Jerry Wheeler."

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myCalendar = myNameSpace.GetDefaultFolder (olFolderCalendar)
Set myItem = myCalendar.Items.Find("[Subject] = _
    ""Golf w/ Jerry Wheeler""")

This Visual Basic for Applications example opens the default Contacts folder and finds the first contact filed as "Jones" whose first name is "Brent."

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myContacts = myNameSpace.GetDefaultFolder (olFolderContacts)
Set myItem = myContacts.Items.Find("[FileAs] = _
    ""Jones"" and [FirstName] = ""Brent""")

This Visual Basic for Applications example utilizes UserProperties and finds a custom property named "LastDateContacted" for the contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myContacts = myNameSpace.GetDefaultFolder (olFolderContacts)
Set myContact = myContacts.Items.Find("[FileAs] = _
    ""Jones"" and [FirstName] = ""Brent""")
Set myProperty = _
    myContact.UserProperties.Find("LastDateContacted")
MsgBox "Last Date Contacted: " & myProperty.Value