I'm trying to get information from the Outlook Global Address List (GAL). I've used OLE and Outlook pretty successfully before and I'm connecting and getting some information now, but can't seem to expand the output.

#!perl use strict; use warnings; use Win32::OLE; my $outlook = Win32::OLE->new('Outlook.Application'); die unless $outlook; my $namespace = $outlook->GetNamespace("MAPI"); for my $k (sort(keys(%{$namespace->AddressLists->Item("Global Address +List")->AddressEntries("Lastname,Firstname")}))) { printf "$k = %s\n", $namespace->AddressLists->Item("Global Address + List")->AddressEntries("Lastname,Firstname")->$k; }

The above produces the following output (admittedly the Lastname,Firstname has been changed as well as the data retuned in 'ID' to obfuscate any sensitive data):

VinsWorldcom@C:\Users\VinsWorldcom\tmp> test.pl Address = /O=EXCHANGE/OU=ORG/CN=RECIPIENTS/CN=LASTNAFI1 AddressEntryUserType = 0 Application = Win32::OLE=HASH(0x2821978) Class = 8 DisplayType = 0 ID = 00000000AABBCCDDEEFFAABBCCDDEEFFAABBCCDDEE00000000000000AABBCCDDE +EFFAABBCCDDEEFFAABBCCDDEEFFAABBCCDDEEFFAABBCCDDEEFFAABBCCDDEEFFAABBCC +DDEEFFAABBCCDDEE00 Name = Lastname,Firstname Parent = Win32::OLE=HASH(0x28219f0) PropertyAccessor = Win32::OLE=HASH(0x2821990) Session = Win32::OLE=HASH(0x2821a08) Type = EX

The issue is the only relevant information from the output above is "Name". Looking at the GAL in Outlook, there are a ton of other fields (e.g., Address, phone number, email address, manager, etc.). I did a "print pack 'H*', $<ID>" and a bunch of hex is the first part followed by the content in the "Address" output. Certainly not enough encoded data to produce all the missing fields.

I've done some expansion of the "Win32::OLE=HASH(...)" values and they don't return anything useful either - just values for:

Application = Win32::OLE=HASH(0x26c16c0) Class = 112 Parent = Win32::OLE=HASH(0x26c1720) Session = Win32::OLE=HASH(0x26c16d8)

Some Google-ing has produced (among others):

UPDATE: Reference here: https://msdn.microsoft.com/en-us/library/office/ff869721.aspx and solved it.

for my $k (sort(keys(%{$namespace->AddressLists->Item("Global Address +List")->AddressEntries("Lastname,Firstname")->GetExchangeUser}))) { printf "$k = %s\n", $namespace->AddressLists->Item("Global Address + List")->AddressEntries("Lastname,Firstname")->GetExchangeUser->$k; }

In reply to SOLVED: Info from Outlook Global Address List by VinsWorldcom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.