3

I'm trying to pull some properties from an Outlook.ExchangeUser object using VBA. I can pull most of what I need, except some data that seems to be stored using the Exchange extended attributes

Questions:

  1. Is it possible to pull the extended attributes using VBA?
  2. If so, how?

Here is some code to give an idea on what I'm doing (this is VBA code in a Microsoft Excel file):

...
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
...

I can then pull the properties using the Exchange user object. I.e...

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

If I try to do something like the above to pull the Extended attributes, I get an error like "Object doesn't support this property or method". I have tried the following to no avail:

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

I also tried using a PropertyAccessor...

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

I got the schema from here but I'm not positive that is correct. I do NOT get an error when I try that, it just comes back empty (nothing is pulled). I tried looking for a list of property tags so I could try others, but I can't seem to find them. If someone knows where to get those maybe that can help too.

Any help is appreciated. Thanks!

Community
  • 1
  • 1
flowjoe
  • 105
  • 8

1 Answers1

0

I found a way to access what I needed. Basically I ended up using a Property Accessor, once I found the correct property tag. In my case (for extension attribute #7) the correct one was "0x8033001F". So I used:

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

For anyone having a similar need but perhaps a different extension attribute, I suggest downloading and installing OutlookSpy (or similar tool). That's the only way I was able to discover the correct property tag, as I was never able to find it by browsing the Microsoft docs.

Hope this helps someone!

flowjoe
  • 105
  • 8