Accessing Global Address List details with VBA

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
0
Utf
2/11/2010 10:28:12 PM
outlook.program_vba 490 articles. 0 followers. Follow

1 Replies
2157 Views

Similar Articles

[PageSpeed] 14

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)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"Dugutigi" <Dugutigi@discussions.microsoft.com> 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 


0
Dmitry
2/11/2010 11:41:39 PM
Reply:

Similar Artilces:

Access 97 can't resize database window
My database window with the listings of forms tables etc was adjusted to a smaller width, but resizing it is completely disabled and renders Access 2007 utterly useless for me. Is there anyway to 'reset' the window? ...

How to link with an Access DB
Hi, I have an Acces DB with many tables. I need to choose the name of a customer in a cell of Excel. For example, in acces I have this tables: Table1 Id Name Last Name City I need to choose the last name from a drop down menu in a spreadsheet and then in other cell I need to put all the data regarding the last name that I choose. I hope to be exaustive, and sorry for my english. :-) Many Thanks Stefano ...

ignore list
I have importet some contact data into mscrm, When I want to add these contacts to a marketing list (add marketing list members / use advanced find/ add all selected members), the adding stops with an error. I have done a trace during the error (occurs everytime I want to add these contacts) which shows me the following error: [2009-08-24 11:15:36.778] Process:OUTLOOK |Thread:5884 |Category: Unmanaged.Platform |User: PlatformUser |Level: Error | Found crmId {319C876A-CC39-DC11-9F61-0030485C3892} in ignore list. Update notification will be ignored Function: CItemHelper<struct Outlook::_Co...

Drop-down list #5
I created a drop-down list in a separate sheet in my workbook. I named it Vehicles. Now I want to add to the list, but I can't figure out how to do it. I know ig must be so easy, but I'm stumped. Please help. If it's a one-time occurrence, you can press Ctrl+F3, click on the name, and extend the formula. Otherwise, I would make the range dynamic. You can learn how to do that here: http://www.contextures.com/xlNames01.html#Dynamic HTH Jason Atlanta, GA >-----Original Message----- >I created a drop-down list in a separate sheet in my workbook. I named it >Vehicles...

Email with no address, subject or content
Please bear with me if this subject has been covered ad nauseum, but I frequently receive email with no "From:" address, no subject and no apparent content. I'm running Outlook 2002. Can anyone tell me what's going on here? Is it an attempt to plant a Web bug? Regardless, I would like to create a rule that automatically dumps such mail in my spam folder. Using the rules wizard I see how to redirect email from a specific address, but leaving the address field blank doesn't work. Thanks in advance for any help. mb ...

[Access 2007] How to edit custom menubar created in Access2003?
Hello, This is my first post to this server, Hello everyone. We're working on a database created by my collegue in MS Access 2003. Since some time we've moved to MS Access 2007. Now we find problems editing the menubar. Each time we want to remove/add/alter a menu item my collegue goes to his MS Access 2003 and changes a menu. In 2007 the full menubar is visible under Add-Ins ribbon menu. Normally there should be a system table USysRibbon, but it is not there. There are only MSys* objects. How can we change the menubar directly in MS Access 2007? Is that possible at al...

Access 2003 resets form variables during debugging while the form is open
Hello, I am using MS Access 2003. (FWIW, this is about an ADP project, not MDB.) A form has a variable that is initialized (by some function call) in Form_Load() and then stays unchanged for the form's entire lifetime. (In a language more advanced than VBA, it would be a constant, not a variable; unfortunately, in VBA I cannot initialize a constant by non- constant expression). Specifically, in my case it looks like this: Private sTempFileName as String ... Private Sub Form_Load() ... sTempFileName = GenerateTempFileName(...) ... End Sub Priv...

Using rules wizard to send to a list of emails addys in BCC
i need to setup an automatic mailing of a newsletter that i receive, to be forwarded to a list of emails addresses, where the emails are inserted into the BCC line, and not the TO line. I do not want my clients to see each other's emails. thanks! No, natively you can't. Even when you use a template to reply with and fill in the BCC field it won't work. It is even worse this way; the rule gets deactivated completely. But programmatically it is possible although not supported by Microsoft. For more info; http://www.slipstick.com/dev/code/autobcc.htm -- Robert Sparnaaij [M...

Too Many IF Statements Nesting Error (Excel Formula Loop w/o VBA)
Hello Excel Problem Gurus, First of all, let me thank you in advance. I find it exemplary that you all can devote time to helping others who are having issues with their work. Hopefully one day I can be at a mentor level, and help others too. Hope you can help! I have an issue where I don't know how to write the formula that I need without going over on the nesting. The current formula that I have is as follows: =IF(OR(B7="",J7="",L7="",M7="",N7="",O7="",P7=""),"No Data",IF(V7="Yes",&qu...

users with restricted access
We have some users that we have directed to only get their information from a report that has been set up. Because of that, I set up a parameter query to make the information more easy to see. The parameter query prompts for last name or broker #, is there a way, when the last name is entered to include Jr's & Sr's? Or should this be another field in the table to make the last name field more accurate? ...

Access 97/2000/2003 comparisons
I have a rather large application that uses an access 97 database (DAO). We also have a version that works with access 2000, Oracle, msde, and SQLServer (ADO). We would like to retire the DAO version of the product, but there are places where the ADO version is much slower compared to where we run DAO seeks (very noticeable when looping). So, I have a few questions. 1. Are there any tips/tricks to speed up ADO queries to compare with DAO seeks? 2. Would there be any benifit in using access 2003 over previous versions of the software besides the added features (xml support, etc). 3...

Using later version of microsoft access
Hi, I've got access 2000 on my computer. When I go to open a database someone sent me I get an error message : this database is in an unrecognized format. The database may have been created with a later version of microsoft access. Is there any way I can open and use this file (short of upgrading to later version of access)? If you do not have Access 2002 or 2003, ask the person to save it in Access 2000 format for you. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at m...

Outlook 2007 addresses
How can I find the list of addresses I have sent emails to? When you start a new email you can put a letter in the To line and list will come up. Where is that list? How can I print it out? Thanks Matt that is the autocomplete cache. You would need a utility to print it out. http://www.outlook-tips.net/archives/2004/20040621.htm http://www.slipstick.com/problems/nicknamecache.asp -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Out...

Follow up Flags not detailed
when I click on Follow up drop down all I get is Flag Message? I want to see the normal ones. Also I would like to set the quick click to default to Custom Flag. What version of Outlook are you using? You can't set the Quick Click to Custom, but you can script around that a little if you're willing to do so. I have a script in AutoHotKey that I use that when I press Windows Key + ` prompts me for a day/date and when I type it in the script applies that date to a custom flag on the selected item. -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower http://www....

no access to send internet email
Hi, Exchange 2003. Can a mail enabled user be restricted to send internal email only and not internet email? Nich Hello, > Exchange 2003. Can a mail enabled user be restricted to send internal email > only and not internet email? yes, that is possible. There are multiple ways to archive this goal. Depents on your infrastructure,too. If you have mailing to external over an SMTP Connector, try this: First look into your SMTP Connector, you will find Delivery Restrictions there. It is self explaining. If you have trouble with that or you won't find it, then i will need additi...

Global distribution List Not Appearing in Outlook Global Selections list
I have created a global list in AD in Server 2003 ( using Exchange 2003) and assigned my users. For some reason the list is not showing in the Outlook client global address list. I have compared this list to others i have created in the past and cannot spot any differences. What am I missing? 1. Have you got it hidden from the GAL? 2. Using cached Exchange mode? Therefore requiring a rebuild of the OAB to see it? Oliver On Fri, 16 Feb 2007 13:24:05 -0500, "rlm" <rmorton@execpc.com> wrote: >I have created a global list in AD in Server 2003 ( using Exchange 2003...

Dynamic Range Selection Using VBA
What I'm trying to accomplish is to be able to run a procedure that selects a range based on a number provided in another cell. For example; if the number 10 is in cell A1, then cells A20:A30 would be selected when I run the macro. If the number 6 is provided, then cells A20:A26 would be selected. Not sure where to start, so any help is appreciated. this may do what you want range("A20").Resize(range("A1").Value+1).select -- Gary Keramidas Excel 2003 "TEK" <TEK@discussions.microsoft.com> wrote in message news:DA9FFF99-FC28-...

Customize columns in 'Marketing List Members'
I can't figure out where one can customize the columns used within the "marketing list" entitry when you click the 'marketing list members' on the left side to show the members. I want to add some columns, like Email. Screenshot: http://i355.photobucket.com/albums/r469/canadaka_bucket/marketing_list_members.jpg Just read the Posting on the Microsoft CRM Team Blog. <canadaka@gmail.com> schrieb im Newsbeitrag news:306584c6-2043-4962-b12a-d0b9287684bb@b31g2000prb.googlegroups.com... > I can't figure out where one can customize the columns used within the >...

Changing ip address of exchange server #2
Hi, I have a back-end server and a smtp server in DMZ. I want to change ip address of back-end server. are there any issues? all incoming and outgoing emails are going via smart host. Hi, No issues at all as long as you remember to change all the references to this server in your firewall, SMTP scanner etc. Leif "Jack Dorson" <JackDorson@discussions.microsoft.com> wrote in message news:FE5927A1-D20D-4C6B-991F-2E1EFD19434D@microsoft.com... > Hi, > > I have a back-end server and a smtp server in DMZ. > > I want to change ip address of back-end server. are ...

how to automatically update inventory list with sales
Please provide the help on how to update the inventory list when some items are sold. Do you want to check this out while you wait for an answer? http://office.microsoft.com/en-us/FX011429711033.aspx Epinn "lalani" <lalani@discussions.microsoft.com> wrote in message news:07A10BC7-97FB-4E93-A686-CAAE3AA2DE88@microsoft.com... > Please provide the help on how to update the inventory list when some items are > sold. The page that Epinn points out is probably as good as any. Excel is a rather poor tool for trying to track inventory. You'll notice that the actual...

Refreshing list boxes
Hi, I have created a database so that mulpile users can add detailss to the table - tblDetails from the form frmDetails or amend details in form frmAmend. I have a list box on the main page frmMain which has a list box lstSearch which shows all the records in the database. When users add new record to the database other users cannot see the added records unless the move to another section in the datbase and the return to the main page thus refreshing the list box. Can anyone tell me if there is a way I can put a "Refresh" button on the main page that updated the list box if the use...

VBA form
Im using a form/macro that i linked to through another thread and a tailoring it to my needs. I basically have it doing what i need but cant get a button to do what i want. When the user starts the macro i brings up the form with a message and 2 buttons (Continue/Cancel). Whe continue is pressed i want the message on the form to change to aniothe message and so on until all messages are shown. Ive attacehed what i working on and apprecaite any help offered. Thank yo +------------------------------------------------------------------- |Filename: Excel.zip ...

Migrating Exchange servers
We are in the process of migrating to a new exchange server. The issue we are having is transfering the user's outlook (xp, 2k) address book/contact list to the new server without manually having to log into everyone's computer and pointing their address books to the new server. Is there a way to do this authomatically server-side? You're moving the mailboxes, right? The user's "address book" is the Contacts folder in the mailbox. So, there's nothing extra to move. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for ...

Excel List Sorting Problem (Descending)
Hi there, I'm having trouble sorting my list--my column contains *only* 4-digit numbers but when I click on "descending order", only about the first half of the rows are arranged this way, before it begins again to arrange the rest in descending order. Like this: 5120 5119 5118 4000 3050 5116 4112 etc. Has this problem happened for anybody else? I'd appreciate any help you can offer. Part of your list is text, although it looks like numbers. Format an empty cell as number. Enter the number 1. Copy. Select your "numbers". Edit>Paste Special, check Mul...

upgrading from Access 97 to Access 2007
I designed a database (forms, reports, et al) several years ago in Access 97 and it continues to work well. I've just received a MS Office Professional 2007 and wonder if it is time to migrate my data into the new program. I've attempted two or three times to do this in Access 2002 and I keep getting error messages along the line of "...corrupted file..cannot be opened by Access 2002 (or some such message)..." The help radio button opens up a box which suggests I do some programming in Virtual Basic to perform my transfer task. The easy way out, of course, is to sti...