Home > Enterprise >  Can I reach Global Address List language independently?
Can I reach Global Address List language independently?

Time:07-22


I would like to create an excel tool which at some point of the operation opens the Global Address List of the Outlook. I have figured it out how to do this, but there was an issue when we tried it on a German languaged computer. I have solved it by check the UI language prior to opening the address book, but I wondered if there is a language independent way to do so? (So I don't need to create a case for every possible languages.)
My corresponding code portion is:
langCode=Application.LanguageSettings.LanguageID(msoLanguageIDUI)
Select Case langCode
 Case &H409
  galStr="Global Address List"
 Case &H40E
  galStr="Globális címlista"
 Case &H407
  galStr="Globale Addressliste"
 Case Else
  galStr="Global Address List"
End Select 

Set olApp=GetObject(,"Outlook.Application")

Set olGAL=olApp.GetNamespace("MAPI"). AddressLists(galStr)

Many thanks for your help.

CodePudding user response:

For user language and programming language independence there is enumeration.

OlAddressListType enumeration (Outlook)

CodePudding user response:

Instead of trying to find the correct localized sting you may iterate over all address lists and get the GAL in the following way:

If(addrList.AddressListType ==
            Outlook.OlAddressListType.olExchangeGlobalAddressList) Then
 ' this is GAL
End If

You can use the NameSpace.CreateRecipient function which creates a Recipient object. After resolving a recipient against the address book you may get the email address.

Also I've found the following article - Get the Global Address List or a set of address lists for a store which you may find helpful.

CodePudding user response:

Use Namespace.GetGlobalAddressList - it will return the GAL of the primary Exchange account in the profile.

As for the AddrList.AddressListType property, it will return olExchangeGlobalAddressList only for the GAL of the primary Exchange account. For a secondary account, it will be a generic olExchangeContainer.

If you have more than one Exchange account in the profile, you can figure out if a particular address list is GAL by reading two MAPI properties using AddressList.PropertyAccessor: PR_AB_PROVIDER_ID must "DCA740C8C042101AB4B908002B2FE182"and PR_DISPLAY_TYPE must be DT_GLOBAL (0x00020000).

If using Redemption (I am its author) is an option, besides exposing RDOSession.Addressbook.GAL (similar to Namespace.GetGlobalAddressList in OOM), it also exposes RDOExchangeAccount.GAL property on the account level (AllRooms property is also exposed).

  • Related