Outlook 兑换:GetNamesFromIDs

发布于 2024-07-07 19:03:46 字数 988 浏览 11 评论 0原文

我正在尝试从 Outlook 项目获取所有属性名称/值。 除了默认的 Outlook 项目属性之外,我还有自定义属性。 我正在使用赎回来绕过 Outlook 警告,但我在 Redemption.RDOMail 项目上的 GetNamesFromIDs 方法上遇到一些问题......

我正在使用我的赎回会话来获取消息并尝试使用该消息来获取所有属性的名称。

Dim rMessage as Redemption.RDOMail = _RDOSession.GetMessageFromID(EntryID, getPublicStoreID())
Dim propertyList As Redemption.PropList = someMessage.GetPropList(Nothing)
For i As Integer = 1 To propertyList.Count + 1
    Console.WriteLine(propertyList(i).ToString())
    Console.WriteLine(someMessage.GetNamesFromIDs(________, propertyList(i)))
Next

我不完全确定将什么作为第一个参数传递给 getNamesFromIDs。 GetNamesFromIDs 的定义如下:

GetNamesFromIDs(MAPIProp as Object, PropTag as Integer) As Redemption.NamedProperty

我不完全确定应该将什么作为 MAPIPProp 对象传入。 我没有看到文档中引用此属性。 http://www.dimastr.com/redemption/rdo/MAPIProp.htm# 任何帮助或见解将不胜

感激。

I'm trying to get all property names / values from an Outlook item. I have custom properties in addition to the default outlook item properties. I'm using redemption to get around the Outlook warnings but I'm having some problems with the GetNamesFromIDs method on a Redemption.RDOMail Item....

I'm using my redemption session to get the message and trying to use the message to get the names of all the properties.

Dim rMessage as Redemption.RDOMail = _RDOSession.GetMessageFromID(EntryID, getPublicStoreID())
Dim propertyList As Redemption.PropList = someMessage.GetPropList(Nothing)
For i As Integer = 1 To propertyList.Count + 1
    Console.WriteLine(propertyList(i).ToString())
    Console.WriteLine(someMessage.GetNamesFromIDs(________, propertyList(i)))
Next

I'm not totally sure what to pass in as the first parameter to getNamesFromIDs. The definition of GetNamesFromIDs is as follows:

GetNamesFromIDs(MAPIProp as Object, PropTag as Integer) As Redemption.NamedProperty

I'm not totally sure what should be passed in as the MAPIProp object. I don't see this property referenced in the documentation. http://www.dimastr.com/redemption/rdo/MAPIProp.htm#properties

Any help or insight would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七分※倦醒 2024-07-14 19:03:46

我想我明白了。 我只使用过VBA,所以你需要“思考”它的局限性,它将遵循VB.NET中相同的方案。

函数签名是这样的:

Function GetNamesFromIDs(MAPIProp As Unknown, PropTag As Long) As NamedProperty

作为第一个参数,它需要一个支持 IUnknown 接口的对象。 查看 Redemption 文档,可以清楚地看到有一个名为 _MAPIProp 的接口,许多其他 RDO 对象都是从该接口派生的(IRDOMail 就是其中之一)。 所以这一定是您试图从中获取数据的RDOMail

知道这一点后,只需要文档中的另一个微妙提示即可使其正常工作:

给定一个 prop 标签 (>= 0x80000000),
返回指定名称的 GUID 和 id
属性。

所以属性标签必须是 >= 0x80000000,这意味着它不适用于所有属性,而仅适用于自定义属性(我想这就是这种情况下的区别,如果我错了,请纠正我) .) 传入不满足此条件的属性标记会引发错误消息(0x8000ffff“意外结果”)。

这是我的代码。 它是 VBA,所以请原谅我的 Hex() 错误,因为 VBA 的长整数对于那么大的数字会溢出。 我相信你会明白的。

Sub GetNamesFromIds()

  Dim rSession As New Redemption.RDOSession
  Dim rMessage As Redemption.RDOMail
  Dim PropertyList As Redemption.PropList
  Dim PropTag As Long
  Dim EntryId As String
  Dim i As Integer

  rSession.MAPIOBJECT = Application.Session.MAPIOBJECT

  ' retrieve first random mail for this example '
  EntryId = ActiveExplorer.CurrentFolder.Items(1).EntryId
  Set rMessage = rSession.GetMessageFromID(EntryId)
  Set PropertyList = rMessage.GetPropList(0)

  For i = 1 To PropertyList.Count
    PropTag = PropertyList(i)
    If "0x" & Right("00000000" & Hex(PropTag), 8) > "0x80000000" Then
      Debug.Print
      If IsArray(rMessage.Fields(PropTag)) Then
        Debug.Print Hex(PropTag), "(Array:", UBound(rMessage.Fields(PropTag)), "items)"
      Else
        Debug.Print Hex(PropTag), "(", rMessage.Fields(PropTag), ")"
      End If
      Debug.Print "    GUID:", rMessage.GetNamesFromIds(rMessage, PropTag).GUID
      Debug.Print "      ID:", rMessage.GetNamesFromIds(rMessage, PropTag).ID
    End If
  Next

End Sub

输出的第一个片段:

8041001E      (             urn:content-classes:message )
    GUID:     {00020386-0000-0000-C000-000000000046}
      ID:     content-class

I think I figured it out. I have used VBA only, so you need to "think around" it's limitations, it will follow the same scheme in VB.NET.

The function signature is this:

Function GetNamesFromIDs(MAPIProp As Unknown, PropTag As Long) As NamedProperty

As the first parameter it requires an object which supports the IUnknown interface. Looking at the Redemption docs it became clear that there is an interface named _MAPIProp, from which many other RDO objects are derived (IRDOMail is among them). So this must be the very RDOMail you are trying to get data out of.

Knowing that, it needed only one other subtle hint from the docs to get it working:

Given a prop tag (>= 0x80000000),
returns the GUID and id of the named
property.

So property tag must be >= 0x80000000, this means it wont work for all properties, but just for the custom ones (I guess that is the distinction in this case, correct me if I'm wrong.) Passing in property tags not fulfilling this condition raises an error message (0x8000ffff "unexpected results").

Here is my code. It is VBA, so forgive me the Hex() blunder, as VBAs long integer overflows for numbers that big. I am sure you will get the picture.

Sub GetNamesFromIds()

  Dim rSession As New Redemption.RDOSession
  Dim rMessage As Redemption.RDOMail
  Dim PropertyList As Redemption.PropList
  Dim PropTag As Long
  Dim EntryId As String
  Dim i As Integer

  rSession.MAPIOBJECT = Application.Session.MAPIOBJECT

  ' retrieve first random mail for this example '
  EntryId = ActiveExplorer.CurrentFolder.Items(1).EntryId
  Set rMessage = rSession.GetMessageFromID(EntryId)
  Set PropertyList = rMessage.GetPropList(0)

  For i = 1 To PropertyList.Count
    PropTag = PropertyList(i)
    If "0x" & Right("00000000" & Hex(PropTag), 8) > "0x80000000" Then
      Debug.Print
      If IsArray(rMessage.Fields(PropTag)) Then
        Debug.Print Hex(PropTag), "(Array:", UBound(rMessage.Fields(PropTag)), "items)"
      Else
        Debug.Print Hex(PropTag), "(", rMessage.Fields(PropTag), ")"
      End If
      Debug.Print "    GUID:", rMessage.GetNamesFromIds(rMessage, PropTag).GUID
      Debug.Print "      ID:", rMessage.GetNamesFromIds(rMessage, PropTag).ID
    End If
  Next

End Sub

First snippet from the output:

8041001E      (             urn:content-classes:message )
    GUID:     {00020386-0000-0000-C000-000000000046}
      ID:     content-class
枕花眠 2024-07-14 19:03:46

好吧,对于背景信息,作者 建议 使用类似 OutlookSpy 查看 Outlook 如何存储属性。

查看 此交流(确保通读所有后续回复),没有更多了(事实上,我认为 Outlook MVP 在某一时刻键入 GetNamesFromIDs 当他的意思是 GetIDsFromNames)。

您可能会尝试使用 GetIDsFromNames 查看返回的内容,然后使用它传递给 GetNamesFromIDs

我以前使用过救赎,但不是以这种特殊的方式,所以这就是我为你提供的一切......

Well, for background info, the author suggests using something like OutlookSpy to see how Outlook stores the properties.

Looking at this exchange (make sure to read through all the follow-up responses), there isn't much more (in fact, I think at one point the Outlook MVP types GetNamesFromIDs when he means GetIDsFromNames).

What you might try is using GetIDsFromNames to see what that returns, and then use that to pass to GetNamesFromIDs.

I've used Redemption before, but not in this particular manner, so that's all I've got for you ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文