Compartilhar via


UserProperties Property

Returns the UserProperties collection that represents all the user properties for the Microsoft Outlook item.

expression**.UserProperties**

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Remarks

Even though olWordDocumentItem is a valid OlItemType constant, user-defined fields cannot to be added to a DocumentItem object and you will receive an error when you try to programmatically add a user-defined field to a DocumentItem object.

Note  

Example

This Visual Basic for Applications (VBA) example finds a custom property named "LastDateContacted" for the contact 'Jeff Smith' and displays it to the user. To run this example, you need to replace 'Jeff Smith' with a valid contact name and create a user-defined property called LastDateContacted for the contact.

Sub FindContact()
'Finds and displays last contacted info for a contact

    Dim olApp As Outlook.Application
    Dim objContact As Outlook.ContactItem
    Dim objContacts As Outlook.MAPIFolder
    Dim objNameSpace As Outlook.NameSpace
    Dim objProperty As Outlook.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 "The contact was not found."
    End If
End Sub

Applies to | AppointmentItem Object | ContactItem Object | DistListItem Object | DocumentItem Object | JournalItem Object | MailItem Object | MeetingItem Object | PostItem Object | RemoteItem Object | ReportItem Object | TaskItem Object | TaskRequestAcceptItem Object | TaskRequestDeclineItem Object | TaskRequestItem Object | TaskRequestUpdateItem Object

See Also | UserProperty Object