NameSpace.CompareEntryIDs 方法 (Outlook)
返回一个 布尔 值,该值指示是否两个条目 ID 值是指同一 Outlook 项目。
语法
expression。 CompareEntryIDs
( _FirstEntryID_
, _SecondEntryID_
)
表达 返回 NameSpace 对象的表达式。
参数
名称 | 必需/可选 | 数据类型 | 说明 |
---|---|---|---|
FirstEntryID | 必需 | String | 要比较的第一个条目 ID。 |
SecondEntryID | 必需 | String | 要比较的第二个条目 ID。 |
返回值
如此 如果条目 ID 的值是指同一 Outlook 项目;否则为 假 。
备注
不能直接对条目标识符进行比较,因为一个对象可以由两个不同的二进制值表示。 使用此方法可以确定两个条目标识符是否代表同一个对象。
示例
(VBA) 示例下面的 Visual Basic for Applications 比较与指定的 AppointmentItem 对象管理器指定的 收件人 对象的项标识符关联的项标识符使用 CompareEntryIDs 方法,并且如果管理器和指定的收件人表示同一个用户,则返回 True 。
Function IsRecipientTheOrganizer( _
ByVal Appt As Outlook.AppointmentItem, _
ByVal Recipient As Outlook.Recipient) As Boolean
Dim objAddrEntry As Outlook.AddressEntry
Dim objPropAc As Outlook.PropertyAccessor
Dim strOrganizerEntryId As String
Dim bytResult() As Byte
Dim objRecipientUser As Outlook.ExchangeUser
Dim objOrganizerUser As Outlook.ExchangeUser
Dim blnReturn As Boolean
'Property tag for Organizer EntryID
Const PR_SENT_REPRESENTING_ENTRYID As String = _
"http://schemas.microsoft.com/mapi/proptag/0x00410102"
' Retrieve an AddressEntry object reference for the
' specified recipient.
Set objAddrEntry = Recipient.AddressEntry
' If the address entry represents an Exchange user
' or Exchange remote user, retrieve an
' ExchangeUser object reference for the sender and
' compare the EntryID value of that object with
' the EntryID of the specified recipient.
If objAddrEntry.AddressEntryUserType = _
OlAddressEntryUserType.olExchangeUserAddressEntry _
Or objAddrEntry.AddressEntryUserType = _
OlAddressEntryUserType.olExchangeRemoteUserAddressEntry Then
' Attempt to retrieve an ExchangeUser
' object reference for the specified
' recipient.
Set objRecipientUser = objAddrEntry.GetExchangeUser()
If objRecipientUser Is Nothing Then
' An Exchange user could not be retrieved
' for the specified recipient.
blnReturn = False
Else
' Retrieve the EntryID property value of the organizer.
' The Organizer property of the AppointmentItem object only
' contains a string representation of the name of the
' organizer, so the PR_SENT_REPRESENTING_ENTRYID property value
' is instead retrieved, using the PropertyAccessor object
' associated with the appointment item.
Set objPropAc = Appt.PropertyAccessor
bytResult = objPropAc.GetProperty( _
PR_SENT_REPRESENTING_ENTRYID)
If Not IsEmpty(bytResult) Then
' Convert the binary value retrieved from the
' PR_SENT_REPRESENTING_ENTRYID property into
' a string value for comparison.
strOrganizerEntryId = _
objPropAc.BinaryToString(bytResult)
' Attempt to retrieve an ExchangeUser
' object reference for the organizer.
Set objOrganizerUser = Appt.Application.Session. _
GetAddressEntryFromID(strOrganizerEntryId).GetExchangeUser()
If objOrganizerUser Is Nothing Then
' An Exchange user could not be retrieved
' for the organizer.
blnReturn = False
Else
' Compare the EntryIDs of the organizer
' and the specified recipient.
blnReturn = Appt.Application.Session. _
CompareEntryIDs( _
objRecipientUser.ID, _
objOrganizerUser.ID)
End If
End If
End If
End If
EndRoutine:
' Clean up
Set objOrganizerUser = Nothing
Set objRecipientUser = Nothing
Set objAddrEntry = Nothing
Set objPropAc = Nothing
' Return the results.
IsRecipientTheOrganizer = blnReturn
Exit Function
ErrRoutine:
Debug.Print Err.Number & " - " & Err.Description, _
vbOKOnly Or vbCritical, _
"IsRecipientTheOrganizer"
GoTo EndRoutine
End Function
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。