Accessing Global Address List details with VBA

Status
Not open for further replies.
D

Dugutigi

I have code that reads names from a local Distribution List and looks up the

name in the Global Address List. The purpose is to retrieve a few of the

details about the user that appear in the properties dialog box ... such as

Street Address, City and State.

My problem is that I only have Outlook 2003 which apparently does not have

the GetExchangeUser object. How can I retrieve these pieces of information

without the GetExchangeUser object?

Here is my code so far ... which works as long as I have manually selected

my local Distribution List. Thanks in advance for any help.

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 x As Long

Set oApp = Outlook.Application

' Get the MAPI namespace.

Set oNS = oApp.Session

' Get the Global Address List.

Set oALs = oNS.AddressLists

Set oGal = oALs.Item("Global Address List")

' Get all the entries.

Set oEntries = oGal.AddressEntries

' Get the first user.

Set oEntry = oEntries.GetFirst()

'Get the currently selected distribution list'

Set olkDL = Application.ActiveExplorer.Selection(1)

For intCount = 1 To olkDL.MemberCount

Set olkEntry = olkDL.GetMember(intCount)

For x = 1 To oEntries.Count

strName = olkEntry.AddressEntry.Name

If oEntry.Name = strName Then

Debug.Print oEntry.Name & ";" & oEntry.Address

GoTo NextIntCount

End If

Set oEntry = oEntries.GetNext

Next x

NextIntCount:

Next intCount

Set olkEntry = Nothing

Set olkDL = Nothing
 
You will either need to use Extended MAPI (C++ or Delphi only), CDO 1.21

(not installed by default, use AddressEntry.Fields[]) or use Redemption

(RDOAddresEntry - see

http://www.dimastr.com/redemption/rdo/rdoaddressentry.htm)

Dmitry Streblechenko (MVP)

-

"Dugutigi" <Dugutigi> wrote in message

news:6B0AFA99-C01E-4920-86D9-8102AA89B659@microsoft.com...
> I have code that reads names from a local Distribution List and looks up
> the
> name in the Global Address List. The purpose is to retrieve a few of the
> details about the user that appear in the properties dialog box ... such
> as
> Street Address, City and State.

> My problem is that I only have Outlook 2003 which apparently does not have
> the GetExchangeUser object. How can I retrieve these pieces of
> information
> without the GetExchangeUser object?

> Here is my code so far ... which works as long as I have manually selected
> my local Distribution List. Thanks in advance for any help.

> 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 x As Long

> Set oApp = Outlook.Application
> ' Get the MAPI namespace.
> Set oNS = oApp.Session
> ' Get the Global Address List.
> Set oALs = oNS.AddressLists
> Set oGal = oALs.Item("Global Address List")
> ' Get all the entries.
> Set oEntries = oGal.AddressEntries

> ' Get the first user.
> Set oEntry = oEntries.GetFirst()

> 'Get the currently selected distribution list'
> Set olkDL = Application.ActiveExplorer.Selection(1)
> For intCount = 1 To olkDL.MemberCount
> Set olkEntry = olkDL.GetMember(intCount)
> For x = 1 To oEntries.Count
> strName = olkEntry.AddressEntry.Name
> If oEntry.Name = strName Then
> Debug.Print oEntry.Name & ";" & oEntry.Address
> GoTo NextIntCount
> End If
> Set oEntry = oEntries.GetNext
> Next x

> NextIntCount:
> Next intCount

> Set olkEntry = Nothing
> Set olkDL = Nothing
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Problem Accessing .MSG Property 'ImageNaturalHeight' Tag '0x80010003' Outlook VBA and Custom Forms 1
M Accessing ALL Outlook contact fields Outlook VBA and Custom Forms 3
RBLampert Accessing Outlook accounts from multiple computers Using Outlook 8
E Accessing shared outlook folder doesn't work since switch to new outlook/excel Outlook VBA and Custom Forms 11
J Accessing calendar items for Resource Mailboxes Outlook VBA and Custom Forms 2
S Outlook [Online - Office365] perfomance is getting affected when accessing the mails using Redemptio Using Outlook 1
J Accessing Hotmail accounts with Outlook 2016 Using Outlook 3
n2b Accessing Plain Text Draft Without Outlook Using Outlook 3
G Issues with accessing Outlook Contact Picture with VBA Outlook VBA and Custom Forms 4
M Accessing ExpiryTime property Outlook VBA and Custom Forms 1
M Accessing BCM with Excel / Running Reports BCM (Business Contact Manager) 1
C Problem accessing events for folder "username" Server Threw Exception Using Outlook 1
P accessing custom task pane with Outlook ActiveInspector Using Outlook 1
mikecox Accessing Outlook on my Win7 desktop from Win8 laptop Using Outlook 1
A "Unable to display the folder" error when accessing Group mailbox Using Outlook 0
Commodore Accessing mail from multiple devices Using Outlook 1
S Programmatically accessing Outlook Calendar data Using Outlook 1
E Accessing User Defined Fields in BCM Database part 2 BCM (Business Contact Manager) 0
E [SOLVED] Accessing User Defined Fields in BCM Database part 1 BCM (Business Contact Manager) 9
R Accessing folder 'Other Contacts' Outlook VBA and Custom Forms 1
E Accessing a Form Region from an Inspector Outlook VBA and Custom Forms 3
E Accessing a Form Region from an Inspector Outlook VBA and Custom Forms 3
H Accessing a control on a frame in Outlook with VBScript Outlook VBA and Custom Forms 1
K Programmatically accessing Outlook properties Outlook VBA and Custom Forms 3
K assistant accessing from her home computer BCM (Business Contact Manager) 2
A Accessing .pst folder in outlook using VBA Code Outlook VBA and Custom Forms 4
J Outlook closes when accessing History in BCM BCM (Business Contact Manager) 4
B Accessing Outlook 2003 Signature Programmatically using C# Outlook VBA and Custom Forms 6
L Outlook Forms-Accessing Outlook VBA and Custom Forms 1
C Accessing _RecipientControl1 (Assigned To) Outlook VBA and Custom Forms 2
K Accessing contact's custom properties in a Outlook 2007 form region Outlook VBA and Custom Forms 1
V Outlook custom form - installing and accessing Outlook VBA and Custom Forms 1
A Daily hours of recurring/ multi-day appts, & accessing mult calend Outlook VBA and Custom Forms 2
R New users creating get page cannot be displayed when accessing OWA Exchange Server Administration 16
Diane Poremsky How to perform a global search and replace Using Outlook 0
I Global variables in ThisOutlookSession Outlook VBA and Custom Forms 1
Diane Poremsky Hiding Global Address Book Fields Using Outlook 0
E Are reminders local or global? Using Outlook 2
L Adding sender's e-mail to global address book DL Outlook VBA and Custom Forms 1
F Outlook 2010, reading pane, global settting for fields? Using Outlook 1
S change default contact list in Outlook 2010 to "contacts" rather than "global" Exchange Server Administration 1
C How do I hide distribution list from global contacts for certain users? Exchange Server Administration 1
H Cannot share calendar, global address book not updating Exchange Server Administration 1
K Extract Global Address List Using Outlook 1
R Outlook 2003 - Exchange 2010 global address list not updating Using Outlook 3
L How do I set up or transfer a distribution list into Global contac BCM (Business Contact Manager) 1
B How to Get Username from Global Address Book Outlook VBA and Custom Forms 1
A Outlook 365 Delete entries in title field, address book Using Outlook 0
P Email address auto-completes work fine on laptop, but no longer on desktop Using Outlook 3
H Copying email address(es) in body of email and pasting in To field Outlook VBA and Custom Forms 1

Similar threads

Back
Top