Does anyone know if there is an API Function that I can call to get an email
address from Outlook given an display name? Most of the employees at our
company have their names setup the same in the company employee database as
in Exchange, but occassionally there are a few differences. I know that
when you're creating an email there is a resolve function that resolves the
names you're adding as recipients, but I need to get that email address
outside of that context.
TIA!
Stephanie Conroy [MSFT] - 29 Oct 2004 20:21 GMT
Hi Bryan. I believe that searching the items collection of the
AddressEntries object will help you. This search is setup so it will return
the first match of any substring you enter. For example:
AddressEntries.Item("Stephanie Conroy") --> returns an AddressEntry object
for me
AddressEntries.Item("Stephanie") --> returns an AddressEntry object for the
first Stephanie found, eg. Stephanie Anderson if such an employee existed.
Here is an outlook macro I wrote to demonstrate getting the email address.
You will have to parse the return value to create the actual email address.
Hope this helps
Output of macro:
Name: Stephanie Conroy
Address: /o=microsoft/ou=First Administrative
Group/cn=Recipients/cn=stefcon
Sub GetAddressFromName()
Dim outapp As Outlook.Application
Dim abLists As Outlook.AddressLists
Dim abl As Outlook.AddressList
Dim abEntries As Outlook.AddressEntries
Dim abEntry As Outlook.AddressEntry
Set outapp = New Outlook.Application
Set abLists = outapp.Session.AddressLists
Set abl = abLists("Global Address List")
Set abEntries = abl.AddressEntries
Set abEntry = abEntries.Item("Stephanie Conroy")
Debug.Print "Name: " & vbTab & abEntry.Name
Debug.Print "Address: " & vbTab & abEntry.Address
Set abEntry = Nothing
Set abEntries = Nothing
Set abl = Nothing
Set abLists = Nothing
Set outapp = Nothing
End Sub
Stephanie Conroy
Software Test Engineer, Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
> Does anyone know if there is an API Function that I can call to get an
> email
[quoted text clipped - 8 lines]
>
> TIA!