Here's a function that will retrieve the email address of a user given their name. It uses the Outlook application to create a new mail item, add the user name as the recipient and then resolves the names before retrieving the email address of the user.
Private outlookApp As Object
Public Function GetUserEmailAddress(userName As String) As String
Dim mailItem As Object
Dim recipient As Object
If outlookApp Is Nothing Then Set outlookApp = CreateObject("Outlook.Application")
GetUserEmailAddress = "[Not Found]"
Set mailItem = outlookApp.CreateItem(0)
mailItem.Recipients.Add userName
If Not mailItem.Recipients.ResolveAll Then Exit Function
Set recipient = mailItem.Recipients(1)
Select Case recipient.AddressEntry.Type
Case "SMTP"
GetUserEmailAddress = recipient.AddressEntry.Address
Case "EX"
GetUserEmailAddress = recipient.AddressEntry.GetExchangeUser.PrimarySmtpAddress
End Select
End Function
WBD
Bookmarks