应用于 UserProperties 对象的 Find 方法。
查找并返回请求的属性名称对应的 UserProperty 对象(如果存在)。
expression.Find(Name, Custom)
expression 必选。该表达式返回上述对象之一。
Name 必选,String 类型。请求的属性的名称。
Custom 可选,Variant 类型。定义搜索参数的自定义字符串。
本 Visual Basic for Applications 示例查找联系人的名为“LastDateContacted”的自定义属性。
Sub FindContact()
'Finds and displays last contacted info for a contact
Dim olApp As Outlook.Application
Dim objContact As ContactItem
Dim objContacts As MAPIFolder
Dim objNameSpace As NameSpace
Dim objProperty As UserProperty
Set olApp = CreateObject("Outlook.Application")
Set objNameSpace = olApp.GetNamespace("MAPI")
Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts)
Set objContact = objContacts.Items.Find("[FileAs] = ""Smith, Jeff"" and [FirstName] = ""Jeff""")
If Not TypeName(objContact) = "Nothing" Then
Set objProperty = objContact.UserProperties.Find("LastDateContacted")
If TypeName(objProperty) <> "Nothing" Then
MsgBox "Last Date Contacted: " & objProperty.Value
End If
Else
MsgBox "Contact not found."
End If
End Sub