Share via


UserDefinedProperties.Add Method

Outlook Developer Reference

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

Version Information
 Version Added:  Outlook 2007

Syntax

expression.Add(Name, Type, DisplayFormat, Formula)

expression   A variable that represents a UserDefinedProperties object.

Parameters

Name Required/Optional Data Type Description
Name Required String The name of the new user-defined property.
Type Required OlUserPropertyType The type of the new user-defined property.
DisplayFormat Optional Variant 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.
Formula Optional Variant 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.

Return Value
A UserDefinedProperty object that represents the new user-defined property.

Example

The following Visual Basic for Applications (VBA) example uses the Add method to create and add several UserDefinedProperty objects to the Inbox default folder.

Visual Basic for Applications
  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 = .<strong>Add</strong>("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

See Also