Class ItemProperty (Outlook VBA)

The class ItemProperty represents information about a given item property for a Microsoft Outlook item object. To use a ItemProperty class variable it first needs to be instantiated, for example


Dim ipy as ItemProperty
Set ipy = Session.CreateSharingItem.Move.Items(1).ItemProperties(Index:=1)

For Each

Here is an example of processing the ItemProperty items in a collection.


Dim ipy As ItemProperty
For Each ipy In Session.CreateSharingItem.Move.Items(1).ItemProperties
	
Next ipy

Class

Returns an OlObjectClass constant indicating the object's class. Here you can find possible values for OlObjectClass.


Dim oocsClass As OlObjectClass
oocsClass = Session.CreateSharingItem.Move.Items(1).ItemProperties(1).Class

IsUserProperty

Returns a Boolean value that indicates if the item property is a custom property created by the user.


Sub ItemProperty() 
 'Creates a new mail item and access it's properties 
 Dim objMail As MailItem 
 Dim objitems As ItemProperties 
 
 'Create the mail item 
 Set objMail = Application.CreateItem(olMailItem) 
 'Create a reference to the item properties collection 
 Set objitems = objMail.ItemProperties 
 'Create a reference to the item property page 
 Call DisplayUserProps(objitems) 
End Sub 
 
Sub DisplayUserProps(ByVal objitems As ItemProperties) 
 'Displays the names of all user-created item properties in the collection 
 For i = 0 To objitems.Count - 1 
 'Display name of property if it was created by the user 
 If objitems.Item(i).IsUserProperty = True Then 
 MsgBox "The property " & objitems(i).Name & " was created by the user." 
 End If 
 Next i 
End Sub

Name

Returns or sets a String value that represents the display name for the object.


Dim strName As String
strName = Session.CreateSharingItem.Move.Items(1).ItemProperties(1).Name

Session

Returns the NameSpace object for the current session.

The Session property and the GetNamespace method can be used interchangeably to obtain the NameSpace object for the current session. Both members serve the same purpose. For example, the following statements do the same function:

Type

Returns an OlUserPropertyType constant indicating the type of the specified object. Here you can find possible values for OlUserPropertyType.


Dim oupType As OlUserPropertyType
oupType = Session.CreateSharingItem.Move.Items(1).ItemProperties(1).Type

Value

Returns or sets a Variant indicating the value for the specified custom or explicit built-in property. Read/write.

Even though ItemProperty.Value allows you to get or set an explicit built-in property or a custom property, you can reference explicit built-in properties directly from the parent object, for example, ContactItem.Body. For more information on accessing properties in Outlook, see Properties Overview.


Sub ValueItemProperty() 
 
 Dim cti As Outlook.ContactItem 
 
 Dim itms As Outlook.ItemProperties 
 
 Dim itm As Outlook.ItemProperty 
 
 
 
 Set cti = Application.CreateItem(olContactItem) 
 
 cti.FullName = "Dan Wilson" 
 
 Set itms = cti.ItemProperties 
 
 Set itm = itms.Item("Body") 
 
 itm.Value = "My friend from school" 
 
 cti.Save 
 
 cti.Display 
 
End Sub