Results 1 to 10 of 10
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Accessing Contacts data in Exchange

    Our office is moving from Lotus Notes to Outlook/Exchange. Using Word 2010 VBA, is it possible to access Contact info on the Exchange server? I will know the username, and I would like to retrieve a list of Contacts in the default Contacts folder. If this is possible, could someone suggest some code to get us started?

    Thanks.

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,179
    Thanks
    47
    Thanked 983 Times in 913 Posts
    Pretty much anything is possible by requesting the data from Outlook. A search for "vba read outlook contacts" should bring up plenty of results. Like this:
    https://groups.google.com/forum/#!to...ss/MVVhahZg6Fs

    cheers, Paul

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    But doesn't the code in these samples allow me to get contacts only from folders in my Outlook client? We are looking to go directly to the Exchange server. We would like to retrieve a collection of all Contacts for user JSMITH, for example.

  4. #4
    Star Lounger
    Join Date
    Dec 2009
    Location
    Findlay, Ohio
    Posts
    57
    Thanks
    4
    Thanked 6 Times in 6 Posts
    The only way I've been able to read a users contact list is by opening Outlook using a profile with that user's information. I'm sure there is another way, I just do not know it.
    i.e. http://technet.microsoft.com/en-us/l.../ee692876.aspx
    here's the example to hopefully help you.
    On Error Resume Next
    Const olFolderContacts = 10
    Set objOutlook = CreateObject("Outlook.Application")
    Set objNamespace = objOutlook.GetNamespace("MAPI")
    Set colContacts = objNamespace.GetDefaultFolder(olFolderContacts).It ems

    For Each objContact In colContacts
    Wscript.Echo objContact.FullName, objContact.Email1Address, objContact.BusinessTelephoneNumber
    Next
    Last edited by orangehat; 2013-08-14 at 12:17.

  5. #5
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    Thanks. I've had good success with getting Contact info from the default Contact folder, and even a sub-folder of that. But we would like to go directly to the Exchange server to get Contacts for a specified (by user name) user. We were able to do that with Lotus Notes Address Book, and are hoping to do something similar with Outlook.

  6. #6
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,179
    Thanks
    47
    Thanked 983 Times in 913 Posts
    You need to be the user in question, or a delegate, to access their contacts, anything else is a security breach.

    cheers, Paul

  7. #7
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    Thank you. That's what we've been finding... as I think about it, it seems quite similar to hacking to be able to request all contacts for a given user without, as you say, being the user in question or a delegate.

  8. #8
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    If I use the following code, will Session.Folders include the folders of users for whom I am a delegate?

    Thanks.

    Set Session = Outlook.Session
    Set Folders = Session.Folders
    For Each Folder In Folders
    etc....

  9. #9
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,179
    Thanks
    47
    Thanked 983 Times in 913 Posts
    I don't know, but I would post this as a new thread to gain more views.

    cheers, Paul

  10. #10
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts
    Check into Redemption -- a com add-in that allows you to retrieve your contacts, or contacts for whom you are a delegate. "It is accessible to any programming language (VB, VBA, VC++, Delphi, etc.)" I use VBA. I started using it to avoid any security messages to the user and have been happy with it for six+ years. When a client's Exchange moved to the cloud two years ago, I had to update to the latest version, but it's well-maintained and extremely well supported. There are a lot of examples in the on-line documentation.

    Kim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •