I used Account.CurrentUser UID and matched AddressList UID to select the correct list. I don't know if using Store is a better approach, but this one works nicely.
Richard and Dmitry thank you for help.
Also Dmitry I want to thank you for maintaining the only source of all MAPI tags available on the Internet.
Code:
using Microsoft.Office.Interop.Outlook;
const string PR_EMSMDB_SECTION_UID = "http://schemas.microsoft.com/mapi/proptag/0x3D150102";
Application app = new Application();
NameSpace ns = app.GetNamespace("MAPI");
ns.Logon("", "", false, true);
string accountName = "admin.test@company.com";
string accountUID = null;
// Get UID for specified account name
foreach (Account acc in ns.Accounts)
{
if (String.Compare(acc.DisplayName, accountName, true) == 0)
{
PropertyAccessor oPAUser = acc.CurrentUser.PropertyAccessor;
accountUID = oPAUser.BinaryToString(oPAUser.GetProperty(PR_EMSMDB_SECTION_UID));
break;
}
}
// Select GAL with matched UID
foreach (AddressList GAL in ns.AddressLists)
{
if (GAL.Name == "Global Address List")
{
PropertyAccessor oPAAddrList = GAL.PropertyAccessor;
if (accountUID == oPAAddrList.BinaryToString(oPAAddrList.GetProperty(PR_EMSMDB_SECTION_UID)))
{
foreach (AddressEntry oEntry in GAL.AddressEntries)
{
// do something
}
break;
}
}
}