Lookup Full name from alias (CdoPR_ACCOUNT) in GAL

B

bgcpen

Hello,
I'm trying to find the full name of a person from the alias (CdoPR_ACCOUNT)
in a Global address book. Here is the code i found and adjusted from some
other posts on this board.

Function Item_Open()
Dim myAlias
Dim oSession
Dim myGAddressList
Dim myGEntries
Dim myGEntry
Dim Name


Const CdoPR_ACCOUNT = "AB50C"
myAlias = CdoPR_ACCOUNT
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False


Set myGAddressList = oSession.AddressLists("Global Address List")
Set myGEntries = myGAddressList.AddressEntries
Set myGEntry = myGEntries(myAlias)
Name = myGEntry.Fields(CdoPR_DISPLAY_NAME).Value


oSession.Logoff


Set oSession = Nothing
Set myGAddressList = Nothing
Set myGEntries = Nothing
Set myGEntry = Nothing

End Function


The problem is that the GAL search searches by myAlias (ex. AB50C) and
doesn't not find any entry by that name. So the proper address entry is not
found and it cannot return the full name because it can't find the entry. Is
there any way to search the GAL by the CdoPR_ACCOUNT field?
 
D

Dmitry Streblechenko

Try to create a dummy message, add the given name as a recipient, resolve
the name, delete the message.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
B

bgcpen

The problem with that is that the GAL won't resolve the alias. If i type in
the username in the To: field, it does not bring up the contact info. That's
exactly the problem i need to solve.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top