【问题标题】:Pull Microsoft Exchange custom / extended attributes using VBA?使用 VBA 拉取 Microsoft Exchange 自定义/扩展属性?
【发布时间】:2017-02-14 16:23:09
【问题描述】:

我正在尝试使用 VBA 从 Outlook.ExchangeUser 对象中提取一些属性。我可以提取我需要的大部分内容,除了一些似乎使用Exchange extended attributes 存储的数据

问题:

  1. 是否可以使用 VBA 拉取扩展属性?
  2. 如果是,怎么做?

这里有一些代码可以说明我在做什么(这是 Microsoft Excel 文件中的 VBA 代码):

...
Dim myOlApp As Outlook.Application
Dim addrList As AddressList
Dim exchUser As Oulook.ExchangeUser
...
Set myOlApp = CreateObject("Outlook.Application")
Set addrList = myOlApp.GetNamespace("MAPI").addressLists("SOMELIST")
Set exchUser = addrList.addressEntries("doe, john").GetExchangeUser
...

然后我可以使用 Exchange 用户对象提取属性。即...

MsgBox ("User company name: " + exchUser.CompanyName)

如果我尝试执行上述操作来提取扩展属性,则会收到类似“对象不支持此属性或方法”的错误。我尝试了以下方法无济于事:

exchUser.msExchangeAttributeX  '(where X is a number from 1-15)
exchUser.ms-Exch-Extension-Attribute-X
exchUser.CustomAttributeX
exchUser.ExtensionCustomAttributeX

我也尝试过使用 PropertyAccessor...

exchUser.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x802D001E")

我从here 获得了架构,但我并不肯定这是正确的。当我尝试这样做时,我没有收到错误,它只是空着回来(没有任何内容被拉出)。我尝试查找属性标签列表,以便可以尝试其他标签,但似乎找不到它们。如果有人知道从哪里可以得到这些,那可能也会有所帮助。

感谢任何帮助。谢谢!

【问题讨论】:

    标签: excel outlook exchange-server-2010 vba


    【解决方案1】:

    我找到了一种访问所需内容的方法。基本上,一旦我找到正确的属性标签,我最终使用了属性访问器。就我而言(对于扩展属性#7),正确的是“0x8033001F”。所以我用了:

    exchUser.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x8033001F")
    

    对于任何有类似需求但可能有不同扩展属性的人,我建议下载并安装OutlookSpy(或类似工具)。这是我能够找到正确属性标签的唯一方法,因为我无法通过浏览 Microsoft 文档找到它。

    希望这对某人有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-24
      • 2016-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多