PC Review


Reply
Thread Tools Rate Thread

Accessing Global Address List details with VBA

 
 
Dugutigi
Guest
Posts: n/a
 
      11th Feb 2010
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
 
Reply With Quote
 
 
 
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      11th Feb 2010
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/rd...dressentry.htm)
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Dugutigi" <(E-Mail Removed)> wrote in message
news:6B0AFA99-C01E-4920-86D9-(E-Mail Removed)...
>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



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Outlook Global Address List using VB.NET Lee Microsoft Dot NET Framework 1 16th Oct 2009 12:04 AM
Accessing the Global address list from a hyperlink =?Utf-8?B?Sm9obg==?= Microsoft Outlook Discussion 0 16th Apr 2007 01:16 PM
Code for the topic :E_ACCESSDENIED error when logging into a CDO session to access Global Address Book{Global Address List} deepu Microsoft Outlook 0 19th Sep 2005 12:55 PM
Outlook 2000 Crashes When Accessing Global Address List =?Utf-8?B?a3V6ZQ==?= Microsoft Outlook Discussion 0 9th Feb 2005 09:53 PM
Accessing Outlook Global Address List from C# John Microsoft C# .NET 1 3rd Feb 2004 08:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:25 PM.