Click here to Skip to main content
11,709,581 members (47,714 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: exchange Outlook
this works with the "full name" but not an alais
Function userDetail(theAlias As String) As String
 
Dim olkDL As Outlook.DistListItem
Dim olkEntry As Outlook.Recipient
Dim olkContact As Outlook.ContactItem
Dim intCount As Integer
Dim strAddress As String
Dim strName As String
Dim oApp As Outlook.Application
Dim oNS As Outlook.Namespace
Dim oALs As Outlook.AddressLists
Dim oGal As Outlook.AddressList
Dim oEntries As Outlook.AddressEntries
Dim oEntry As Outlook.AddressEntry
Dim oAlias As Outlook.ContactItem
 
On Error GoTo outlookClosed
 
Set oApp = Outlook.Application
On Error GoTo 0
 
Set oNS = oApp.Session ' Get the MAPI namespace.
Set oALs = oNS.AddressLists ' Get the Global Address List.
Set oGal = oALs.Item("Global Address List") ' Get all the entries.

Alias = LCase(Trim(theAlias))
 
Set oEntries = oGal.AddressEntries
Set oEntry = oEntries(Alias)
 
'********************************************
'OUTPUT
'********************************************

'userDetail = oEntry.GetExchangeUser.JobTitle
'userDetail = oEntry.GetExchangeUser.Alias
'userDetail = oEntry.GetExchangeUser.Department
'userDetail = oEntry.GetExchangeUser.OfficeLocation
'userDetail = oEntry.GetExchangeUser.StreetAddress
'userDetail = oEntry.GetExchangeUser.Address
'userDetail = oEntry.GetExchangeUser.City
'userDetail = oEntry.GetExchangeUser.StateOrProvince
'userDetail = oEntry.GetExchangeUser.MobileTelephoneNumber

'userDetail = oEntry.GetExchangeUser.MobileTelephoneNumber
userDetail = oEntry.GetExchangeUser.OfficeLocation
 
'********************************************
'OUTPUT
'********************************************

Exit Function
 
outlookClosed:
userDetail = False
 
Exit Function
 
End Function
Posted 20-Mar-12 11:58am
Edited 20-Mar-12 12:35pm
(no name)18.2K
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 525
1 OriginalGriff 250
2 Peter Leow 219
3 Maciej Los 185
4 Mika Wendelius 160
0 OriginalGriff 9,428
1 Sergey Alexandrovich Kryukov 9,037
2 CPallini 5,189
3 Maciej Los 4,991
4 Mika Wendelius 3,856


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 20 Mar 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100