Outlook) (UserDefinedProperty 物件

代表 Folder 物件的使用者定義屬性定義。

註解

使用 UserDefinedProperties (索 ) ,其中 index 是名稱或索引編號,可傳回單一 UserDefinedProperty 物件。

使用Folder物件之UserDefinedProperties集合的Add方法,定義該資料夾的使用者定義屬性。

使用 Type 屬性可傳回使用者定義的屬性類型和 DisplayFormat 屬性,以傳回使用者定義屬性的顯示格式。 如果 Type 屬性設定為 olCombinationolFormula,則使用 Formula 屬性可傳回用來為此使用者定義之屬性產生值的公式。

UserDefinedProperty物件只代表使用者定義屬性的定義,該屬性適用于資料夾所包含的所有 Outlook 專案。 若要擷取或變更該資料夾中 Outlook 專案的使用者定義屬性值,請使用 Outlook 專案的 UserProperties 屬性,例如 MailItem 物件,來擷取該專案的 UserProperties 集合。 然後,您可以使用適當使用者定義屬性的 UserProperty 物件,來擷取或變更 Outlook 專案之該使用者定義屬性的值。

範例

下列 Visual Basic for Applications (VBA) 範例會在 [即時運算] 視窗中顯示指定之 Folder 物件的名稱,以及指定之 Folder 物件的 UserDefinedProperties 集合中所包含之每個 UserDefinedProperty 物件的名稱和類型。

Sub DisplayUserProperties(ByRef FolderToCheck As Folder) 
 Dim objProperty As UserDefinedProperty 
 
 ' Print the name of the specified Folder object 
 ' reference to the Immediate window. 
 Debug.Print "--- Folder: " & FolderToCheck.Name 
 
 ' Check if there are any user-defined properties 
 ' associated with the Folder object reference. 
 If FolderToCheck.UserDefinedProperties.Count = 0 Then 
 ' No user-defined properties are present. 
 Debug.Print " No user-defined properties." 
 Else 
 ' Iterate through every user-defined property in 
 ' the folder. 
 For Each objProperty In FolderToCheck.UserDefinedProperties 
 ' Retrieve the name of the user-defined property. 
 strPropertyInfo = objProperty.Name 
 ' Retrieve the type of the user-defined property. 
 Select Case objProperty.Type 
 Case OlUserPropertyType.olCombination 
 strPropertyInfo = strPropertyInfo & " (Combination)" 
 Case OlUserPropertyType.olCurrency 
 strPropertyInfo = strPropertyInfo & " (Currency)" 
 Case OlUserPropertyType.olDateTime 
 strPropertyInfo = strPropertyInfo & " (Date/Time)" 
 Case OlUserPropertyType.olDuration 
 strPropertyInfo = strPropertyInfo & " (Duration)" 
 Case OlUserPropertyType.olEnumeration 
 strPropertyInfo = strPropertyInfo & " (Enumeration)" 
 Case OlUserPropertyType.olFormula 
 strPropertyInfo = strPropertyInfo & " (Formula)" 
 Case OlUserPropertyType.olInteger 
 strPropertyInfo = strPropertyInfo & " (Integer)" 
 Case OlUserPropertyType.olKeywords 
 strPropertyInfo = strPropertyInfo & " (Keywords)" 
 Case OlUserPropertyType.olNumber 
 strPropertyInfo = strPropertyInfo & " (Number)" 
 Case OlUserPropertyType.olOutlookInternal 
 strPropertyInfo = strPropertyInfo & " (Outlook Internal)" 
 Case OlUserPropertyType.olPercent 
 strPropertyInfo = strPropertyInfo & " (Percent)" 
 Case OlUserPropertyType.olSmartFrom 
 strPropertyInfo = strPropertyInfo & " (Smart From)" 
 Case OlUserPropertyType.olText 
 strPropertyInfo = strPropertyInfo & " (Text)" 
 Case OlUserPropertyType.olYesNo 
 strPropertyInfo = strPropertyInfo & " (Yes/No)" 
 Case Else 
 strPropertyInfo = strPropertyInfo & " (Unknown)" 
 End Select 
 
 ' Print the name and type of the user-defined property 
 ' to the Immediate window. 
 Debug.Print strPropertyInfo 
 Next 
 End If 
End Sub 

方法

名稱
Delete

屬性

名稱
Application
Class
DisplayFormat
Formula
Name
Parent
Session
Type

另請參閱

Outlook 物件模型參考

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應