Vba Outlook邮件项目属性访问器返回错误字符串
我试图使用PropertyAccessor显示许多MailItem属性的值,但是我得到的只是不可打印的字符 我还没有找到一个有类似问题的帖子Vba Outlook邮件项目属性访问器返回错误字符串,vba,outlook,properties,Vba,Outlook,Properties,我试图使用PropertyAccessor显示许多MailItem属性的值,但是我得到的只是不可打印的字符 我还没有找到一个有类似问题的帖子 Private Const PRMessageID = "http://schemas.microsoft.com/mapi/proptag/0x1035001E" Private Const PRConvIndex = "http://schemas.microsoft.com/mapi/proptag/0x00710102" Private Const
Private Const PRMessageID = "http://schemas.microsoft.com/mapi/proptag/0x1035001E"
Private Const PRConvIndex = "http://schemas.microsoft.com/mapi/proptag/0x00710102"
Private Const PRSenderEID = "http://schemas.microsoft.com/mapi/proptag/0x0C190102"
Private Const PRParentEID = "http://schemas.microsoft.com/mapi/proptag/0x0E090102"
Private Const PRStoreEnID = "http://schemas.microsoft.com/mapi/proptag/0x0FFB0102"
Private Const PR__EntryID = "http://schemas.microsoft.com/mapi/proptag/0x0FFF0102"
Private Const PRRecordKey = "http://schemas.microsoft.com/mapi/proptag/0x0FF90102"
Private Const PRStrRecKey = "http://schemas.microsoft.com/mapi/proptag/0x0FFA0102"
Private Const PRSearchKey = "http://schemas.microsoft.com/mapi/proptag/0x300B0102"
Public Function AssignMailIDS(oMail As Outlook.MailItem) As String
AssignMailIDS = oMail.ConversationIndex
' oMail.PropertyAccessor.SetProperty PropNameSpace, AssignMailIDS
'
' Debug.Print oMail.PropertyAccessor.getProperty(PropNameSpace)
oMail.ItemProperties.Add("OriginalConvIdx", olText, True) = AssignMailIDS
Debug.Print "+++++"
Debug.Print "-----"
Debug.Print oMail.UserProperties("OriginalConvIdx")
Debug.Print "Message ID " & GetItemID(oMail, PRMessageID)
Debug.Print "Convers ID " & GetItemID(oMail, PRConvIndex)
Debug.Print "Sender EID " & GetItemID(oMail, PRSenderEID)
Debug.Print "Parent EID " & GetItemID(oMail, PRParentEID)
Debug.Print "Store EnID " & GetItemID(oMail, PRStoreEnID)
Debug.Print "Entry ID " & GetItemID(oMail, PR__EntryID)
Debug.Print "Record Key " & GetItemID(oMail, PRRecordKey)
Debug.Print "StrRec Key " & GetItemID(oMail, PRStrRecKey)
Debug.Print "Search ID " & GetItemID(oMail, PRSearchKey)
End Function
Public Function GetItemID(oItem As MailItem, sID As String) As String
On Error Resume Next
GetItemID = "<Non Existant>"
GetItemID = oItem.PropertyAccessor.getProperty(sID)
End Function
Set oOLapp = OpenOutlook()
Set oMapi = oOLapp.GetNamespace("MAPI")
Set oSentFolder = oOLapp.GetNamespace("MAPI").Folders(oMapi.DefaultStore.DisplayName).Folders("Sent Items")
Set oItems = oSentFolder.Items
oItems.Sort "[SentOn]", True
Set oItem = oItems(1) ' Get latest sent item
Debug.Print "-----"
Debug.Print "Message ID " & GetItemID(oItem, PRMessageID)
Debug.Print "Convers ID " & GetItemID(oItem, PRConvIndex)
Debug.Print "Sender EID " & GetItemID(oItem, PRSenderEID)
Debug.Print "Parent EID " & GetItemID(oItem, PRParentEID)
Debug.Print "Store EnID " & GetItemID(oItem, PRStoreEnID)
Debug.Print "Entry ID " & GetItemID(oItem, PR__EntryID)
Debug.Print "Record Key " & GetItemID(oItem, PRRecordKey)
Debug.Print "StrRec Key " & GetItemID(oItem, PRStrRecKey)
Debug.Print "Search ID " & GetItemID(oItem, PRSearchKey)
sItemConvIdx = oItem.UserProperties("OriginalConvIdx")
Private Const PRMessageID=”http://schemas.microsoft.com/mapi/proptag/0x1035001E"
Private Const PRConvIndex=”http://schemas.microsoft.com/mapi/proptag/0x00710102"
私人康斯特普森德雷德=”http://schemas.microsoft.com/mapi/proptag/0x0C190102"
私有常量PRParentEID=”http://schemas.microsoft.com/mapi/proptag/0x0E090102"
私有常量PRSTORENID=”http://schemas.microsoft.com/mapi/proptag/0x0FFB0102"
私有常量PR_uuentryId=”http://schemas.microsoft.com/mapi/proptag/0x0FFF0102"
Private Const PRRecordKey=”http://schemas.microsoft.com/mapi/proptag/0x0FF90102"
私有常量PRStrRecKey=”http://schemas.microsoft.com/mapi/proptag/0x0FFA0102"
私有常量PRSearchKey=”http://schemas.microsoft.com/mapi/proptag/0x300B0102"
公共函数将mailids(oMail作为Outlook.MailItem)分配为字符串
AssignMailIDS=oMail.ConversationIndex
'oMail.PropertyAccessor.SetProperty PropNameSpace,AssignMailId
'
'Debug.Print oMail.PropertyAccessor.getProperty(PropNameSpace)
oMail.ItemProperties.Add(“OriginalConvIdx”,olText,True)=AssignMailIDS
调试。打印“+
调试。打印“-----”
Debug.Print oMail.UserProperties(“OriginalConvIdx”)
调试。打印“消息ID”和GetItemID(oMail,PRMessageID)
调试。打印“Convers ID”和GetItemID(oMail,PRCONVDINDEX)
调试。打印“发件人EID”和GetItemID(oMail、PRSenderEID)
调试。打印“父项ID”和GetItemID(oMail、PRParentEID)
Debug.Print“Store EnID”和GetItemID(oMail、PRStoreEnID)
调试。打印“条目ID”和GetItemID(oMail,PR\uu EntryID)
调试。打印“记录键”和GetItemID(oMail,PRRecordKey)
调试。打印“StrRec Key”和GetItemID(oMail、PRStrRecKey)
调试。打印“搜索ID”和GetItemID(oMail、PRSearchKey)
端函数
公共函数GetItemID(oItem作为MailItem,sID作为String)作为String
出错时继续下一步
GetItemID=“”
GetItemID=oItem.PropertyAccessor.getProperty(sID)
端函数
设置oOLapp=OpenOutlook()
设置oMapi=oOLapp.GetNamespace(“MAPI”)
设置oSentFolder=oOLapp.GetNamespace(“MAPI”).Folders(oMapi.DefaultStore.DisplayName)。Folders(“已发送项目”)
设置oItems=oSentFolder.Items
oItems.Sort“[SentOn]”,对
设置oItem=oItems(1)'获取最新发送的项目
调试。打印“-----”
调试。打印“消息ID”和GetItemID(oItem,PRMessageID)
调试。打印“Convers ID”和GetItemID(oItem、PRCONVDINDEX)
Debug.Print“Sender-EID”和GetItemID(oItem,PRSenderEID)
Debug.Print“Parent-EID”和GetItemID(oItem,PRParentEID)
Debug.Print“Store EnID”和GetItemID(oItem、PRStoreEnID)
调试。打印“条目ID”和GetItemID(oItem,PR\u EntryID)
调试。打印“记录键”和GetItemID(oItem,PRRecordKey)
调试。打印“StrRec Key”和GetItemID(oItem、PRStrRecKey)
调试。打印“搜索ID”和GetItemID(oItem、PRSearchKey)
sItemConvIdx=oItem.UserProperties(“OriginalConvIdx”)
这将导致调试器窗口的以下输出:
+++++
-----
01D34EE4AAEC61381400E9CB4836BA2932216C015C25
Message ID
Convers ID ????????U+
Sender EID <Non Existant>
Parent EID <Non Existant>
Store EnID <Non Existant>
Entry ID <Non Existant>
Record Key <Non Existant>
StrRec Key ????????
Search ID <Non Existant>
-----
Message ID
Convers ID ???????????
Sender EID ??????? ???????????????????????????
Parent EID ???????????????? ??
Store EnID ??????? ????? ???????? ???????????????????????????????????????????8??T Walter.ZAMBOTTI@police.wa.gov.au
Entry ID ???????????????? ?? ????????A??
Record Key ????????????????A??
StrRec Key ????????
Search ID ????????
+++++
-----
01D34EE4AAEC61381400E9CB4836BA2932216C015C25
消息ID
会话ID?????????????U+
发送方EID
父EID
存储EnID
条目ID
记录键
备用钥匙????????
搜索ID
-----
消息ID
会话ID???????????
发送方EID???????????????????????????
家长EID??
商店名为EnID???????????????????????????????????????????沃尔特先生。ZAMBOTTI@police.wa.gov.au
条目ID????????A.
记录键A??
备用钥匙????????
搜索ID????????
我最初试图获取消息ID,但当该ID为空时,我感到惊讶,因此我尝试检索其他值,但没有找到任何有效的值
任何想法都值得赞赏 改用这个
Public Function GetItemID(oItem As MailItem, sID As String) As String
On Error Resume Next
GetItemID = "<Non Existant>"
GetItemID = oItem.PropertyAccessor.BinaryToText(oItem.PropertyAccessor.getProperty(sID))
End Function
公共函数GetItemID(oItem作为MailItem,sID作为String)作为String
出错时继续下一步
GetItemID=“”
GetItemID=oItem.PropertyAccessor.BinaryToText(oItem.PropertyAccessor.getProperty(sID))
端函数
当然,返回的一些字符串实际上是字符串,而其他字符串是需要转换的二进制字符串。这意味着您需要使上述函数接受可选的IsBinary标志,以便您可以选择转换或不转换。如果在
监视窗口中检查GetItemID(oMail,PRMessageID)
,您会看到什么。。。它是一系列字节。。。。似乎不是unicode。。。这里可能是加密数据检查。。。。这是二进制数据。答案是将输出包装在PropertyAccessor.BinaryToText方法中。GetProperty方法在返回字符串时显然会返回需要二进制转换的特殊字符串!!!