Getting details of a person in GAL on Exchange by its alias

P

Petr Bazant

Hello, I have an alias of a person listed in GAL (on Exchange server)
and I would like to obtain programatically its details, like email,
name etc. The alias is stored as the value of field "Item12" but it
always returns an error E_ACCESSDENIED. Is there a way how to do it?

Set objSession = CreateObject("MAPI.Session")
objSession.Logon (g_strMAPILogOn)
Set MyAddressList = objSession.AddressLists(g_strAddressList)
Set MyAddressEntries = MyAddressList.AddressEntries

For Each SomeEntry In MyAddressEntries
Set MyEntry = SomeEntry
If alias = MyEntry.Fields("Item 12").Value Then
...
...
End If
Next


Thank you, Petr
 
P

Petr Bazant

If someone has same problem I found a solution (almost everything was
already answered in this newsgroup). Thanks to everyone.

Type Ohlasovatel
jmeno As String
email As String
End Type

Public Function GetOhlasovatelDetails(ByVal alias As String) As
Ohlasovatel
Dim objSession As MAPI.Session
Dim objField As MAPI.Field
Dim MyAddressList As MAPI.AddressList
Dim MyAddressEntries As MAPI.AddressEntries
Dim MyEntry As MAPI.AddressEntry
Dim SomeEntry As MAPI.AddressEntry
Dim MyRecipient As MAPI.Recipient
Dim v As Variant
Dim strReturnValue As String
Dim jjmeno As String
Dim eemail As String

Set objSession = CreateObject("MAPI.Session")
objSession.Logon (g_strMAPILogOn)
Set MyAddressList = objSession.AddressLists(g_strAddressList)
Set MyAddressEntries = MyAddressList.AddressEntries

For Each SomeEntry In MyAddressEntries
Set MyEntry = SomeEntry
Set objField = MyEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)
If MyEntry.Fields(CdoPR_ACCOUNT) = alias Then
jjmeno = MyEntry.Name
For Each v In objField.Value
If InStr(1, UCase(v), g_strEMailAddressIdentifier)
Then
eemail = Mid(v, 6, 256)
GetOhlasovatelDetails.jmeno = jjmeno
GetOhlasovatelDetails.email = eemail
Exit Function
End If
Next 'Field Value
End If
Next 'Address Entry
End Function


Petr Bazant napsal:
 

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

Similar Threads


Top