Export (0) Print
Expand All

AddressEntry.GetExchangeUser Method

Office 2007
Returns an ExchangeUser object that represents the AddressEntry if the AddressEntry belongs to an Exchange AddressList object such as the Global Address List (GAL) and corresponds to an Exchange user.

Version Information
 Version Added:  Outlook 2007

Syntax

expression.GetExchangeUser

expression   A variable that represents an AddressEntry object.

Return Value
An ExchangeUser object that represents the AddressEntry. Returns Null (Nothing in Visual Basic) if the AddressEntry object does not correspond to an Exchange user.

Remarks

You have to be connected to the Exchange server to use this method.

Example

The following code sample shows how to obtain the business phone number, office location, and job title for all Exchange user entries in the Exchange Global Address List. It first uses AddressList.AddressListType to find the Global Address List. For each AddressEntry on that AddressList, it uses AddressEntryUserType to verify if the AddressEntry represents an Exchange user. After it finds an Exchange user, it uses GetExchangeUser to obtain and print the various pieces of data for the user.

Visual Basic for Applications
Sub DemoAE()
    Dim colAL As Outlook.AddressLists
    Dim oAL As Outlook.AddressList
    Dim colAE As Outlook.AddressEntries
    Dim oAE As Outlook.AddressEntry
    Dim oExUser As Outlook.ExchangeUser
    Set colAL = Application.Session.AddressLists
    For Each oAL In colAL
        'Address list is an Exchange Global Address List
        If oAL.AddressListType = olExchangeGlobalAddressList Then
            Set colAE = oAL.AddressEntries
            For Each oAE In colAE
                If oAE.AddressEntryUserType = _
                    olExchangeUserAddressEntry _
                    Or oAE.AddressEntryUserType = _
                    olExchangeRemoteUserAddressEntry Then
                    Set oExUser = oAE.GetExchangeUser
                    Debug.Print (oExUser.JobTitle)
                    Debug.Print (oExUser.OfficeLocation)
                    Debug.Print (oExUser.BusinessTelephoneNumber)
                End If
            Next
        End If
    Next
End Sub



Community Additions

ADD
Show:
© 2014 Microsoft