Class UserDefinedProperties (Outlook VBA)

Contains a set of UserDefinedProperty objects representing the user-defined properties defined for a Folder object. To use a UserDefinedProperties class variable it first needs to be instantiated, for example


Dim udps as UserDefinedProperties
Set udps = Session.CreateSharingItem.Move.UserDefinedProperties

For Each

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


Dim udp As UserDefinedProperty
For Each udp In Session.CreateSharingItem.Move.UserDefinedProperties
	
Next udp

Add

Creates a new UserDefinedProperty object and appends it to the collection.

You can create a property of a type that is defined by the OlUserPropertyType enumeration, except for the following types: olEnumeration, olOutlookInternal, and olSmartFrom.

Add (Name, Type, DisplayFormat, Formula)


Sub AddStatusProperties() 
 Dim objNamespace As NameSpace 
 Dim objFolder As Folder 
 Dim objProperty As UserDefinedProperty 
 
 ' Obtain a Folder object reference to the 
 ' Inbox default folder. 
 Set objNamespace = Application.GetNamespace("MAPI") 
 Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox) 
 
 ' Add five user-defined properties, used to identify and 
 ' track customer issues. 
 With objFolder.UserDefinedProperties 
 Set objProperty = .Add("Issue?", olYesNo, olFormatYesNoIcon) 
 Set objProperty = .Add("Issue Research Time", olDuration) 
 Set objProperty = .Add("Issue Resolution Time", olDuration) 
 Set objProperty = .Add("Customer Follow-Up", olYesNo, olFormatYesNoYesNo) 
 Set objProperty = .Add("Issue Closed", olYesNo, olFormatYesNoYesNo) 
 End With 
End Sub

Arguments

The following arguments are required:

Name (String) - The name of the new user-defined property.

Type (OlUserPropertyType) - The type of the new user-defined property.

Here you can find possible values for OlUserPropertyType

Optional arguments

The following arguments are optional

DisplayFormat (OlUserPropertyType) - The display format of the new user-defined property. This parameter can be set to a value from one of several different enumerations, determined by the OlUserPropertyType constant specified in the Type parameter. For more information on how Type and DisplayFormat interact, see DisplayFormat Property.

Here you can find possible values for OlUserPropertyType

Formula (String) - The formula used to calculate values for the new user-defined property. This parameter is ignored if the Type parameter is set to any value other than olCombination or olFormula.

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.UserDefinedProperties.Class

Count

Returns a Long value that indicates the count of objects in the specified collection.


Dim lngCount As Long
lngCount = Session.CreateSharingItem.Move.UserDefinedProperties.Count

Find

Locate a UserDefinedProperty contained in the collection.

Find (Name)

Name: The Name property value of the UserDefinedProperty object to find in the collection.


Dim strName As String: strName = 
Dim udpFind As UserDefinedProperty
Set udpFind = Session.CreateSharingItem.Move.UserDefinedProperties.Find(Name:=strName)

Item

Returns an object from the collection.

Item (Index)

Index: Either a Long value that represents the 1-based index number of an object in the collection, or a String value that represents the Name property value of an object in the collection.


Dim udp As UserDefinedProperty
Set udp = Session.CreateSharingItem.Move.UserDefinedProperties(Index:=1)

Refresh

Refreshes the contents of the collection from the store, retrieving any changes performed in remote explorers.


Session.CreateSharingItem.Move.UserDefinedProperties.Refresh

Remove

Removes an object from the collection.

Remove (Index)

Index: The 1-based index value of the object within the collection.


Dim lngIndex As Long: lngIndex = 
Session.CreateSharingItem.Move.UserDefinedProperties.Remove Index:=lngIndex

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 perform the same function: