PropertyAccessor オブジェクト (Outlook)

オブジェクトのプロパティを作成、取得、設定、および削除する機能を提供します。

注釈

PropertyAccessor オブジェクトを使用して、Outlook オブジェクト モデルで明示的に公開されていないアイテム レベルのプロパティ、または AddressEntryAddressListAttachmentExchangeDistributionListExchangeUserFolderRecipientStore のプロパティを取得および設定します。

複数のカスタム プロパティを取得または設定するには、パフォーマンスを向上させるために、UserProperties オブジェクトの代わりに PropertyAccessor オブジェクトを使用します。

PropertyAccessor オブジェクトの使用方法の詳細については、「プロパティの概要」を参照してください。

次のコード サンプルは、 PropertyAccessor.GetProperty メソッドを使用して 、MailItem に属しているが Outlook オブジェクト モデルでは公開されていない MAPI プロパティを読み取る方法 を示PR_TRANSPORT_MESSAGE_HEADERS

Sub DemoPropertyAccessorGetProperty() 
 
 Dim PropName, Header As String 
 
 Dim oMail As Object 
 
 Dim oPA As Outlook.PropertyAccessor 
 
 'Get first item in the inbox 
 
 Set oMail = _ 
 
 Application.Session.GetDefaultFolder(olFolderInbox).Items(1) 
 
 'PR_TRANSPORT_MESSAGE_HEADERS 
 
 PropName = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" 
 
 'Obtain an instance of PropertyAccessor class 
 
 Set oPA = oMail.PropertyAccessor 
 
 'Call GetProperty 
 
 Header = oPA.GetProperty(PropName) 
 
 Debug.Print (Header) 
 
End Sub

次のコード サンプルでは、 PropertyAccessor.SetProperties メソッドが複数のプロパティの値を設定する方法を示します。 プロパティが存在せず、親オブジェクトがそのプロパティの作成をサポートしている場合、SetProperties はプロパティを作成します。 オブジェクトが明示的な Save 操作をサポートしている場合は、明示的な Save 操作を呼び出したときにプロパティがオブジェクトに保存されます。 オブジェクトが明示的な Save 操作をサポートしていない場合は、SetProperties を呼び出したときにプロパティがオブジェクトに保存されます。

Sub DemoPropertyAccessorSetProperties() 
 
 Dim PropNames(), myValues() As Variant 
 
 Dim arrErrors As Variant 
 
 Dim prop1, prop2, prop3, prop4 As String 
 
 Dim i As Integer 
 
 Dim oMail As Outlook.MailItem 
 
 Dim oPA As Outlook.PropertyAccessor 
 
 'Get first item in the inbox 
 
 Set oMail = _ 
 
 Application.Session.GetDefaultFolder(olFolderInbox).Items(1) 
 
 'Names for properties using the MAPI string namespace 
 
 prop1 = "http://schemas.microsoft.com/mapi/string/" & _ 
 
 "{FFF40745-D92F-4C11-9E14-92701F001EB3}/mylongprop" 
 
 prop2 = "http://schemas.microsoft.com/mapi/string/" & _ 
 
 "{FFF40745-D92F-4C11-9E14-92701F001EB3}/mystringprop" 
 
 prop3 = "http://schemas.microsoft.com/mapi/string/" & _ 
 
 "{FFF40745-D92F-4C11-9E14-92701F001EB3}/mydateprop" 
 
 prop4 = "http://schemas.microsoft.com/mapi/string/" & _ 
 
 "{FFF40745-D92F-4C11-9E14-92701F001EB3}/myboolprop" 
 
 PropNames = Array(prop1, prop2, prop3, prop4) 
 
 myValues = Array(1020, "111-222-Kudo", Now(), False) 
 
 'Set values with SetProperties call 
 
 'If the properties don't exist, then SetProperties 
 
 'adds the properties to the object when saved. 
 
 'The type of the property is the type of the element 
 
 'passed in myValues array. 
 
 Set oPA = oMail.PropertyAccessor 
 
 arrErrors = oPA.SetProperties(PropNames, myValues) 
 
 If Not (IsEmpty(arrErrors)) Then 
 
 'Examine the arrErrors array to determine if any 
 
 'elements contain errors 
 
 For i = LBound(arrErrors) To UBound(arrErrors) 
 
 'Examine the type of the element 
 
 If IsError(arrErrors(i)) Then 
 
 Debug.Print (CVErr(arrErrors(i))) 
 
 End If 
 
 Next 
 
 End If 
 
 'Save the item 
 
 oMail.Save 
 
End Sub

メソッド

名前
BinaryToString
DeleteProperties
DeleteProperty
GetProperties
GetProperty
LocalTimeToUTC
SetProperties
SetProperty
StringToBinary
UTCToLocalTime

プロパティ

名前
アプリケーション
Class
Parent
Session

関連項目

Outlook オブジェクト モデル リファレンスPropertyAccessor オブジェクト メンバー

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。