CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2000
    Location
    Sheffield, UK
    Posts
    52

    Outlook97 Addressbook

    Help please,

    I am trying to read the outlook 97 address book into a combo box with the following code but it gives an error.

    Object does not support this property or method

    Dim myOlApp As Object
    Dim myNameSpace As Object
    Dim myAddressList As Object
    Dim myAddressEntries As Object
    Dim i As Integer

    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    Set myAddressList = myNameSpace.AddressLists("Contacts")
    Set myAddressEntries = myAddressList.AddressEntries

    With cboFaxNumbers
    .AddItem myAddressEntries.GetFirst

    For i = 2 To myAddressEntries.Count
    .AddItem myAddressEntries.GetNext
    Next i
    End With

    Help appreciated

    Cheers

    Rob


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Outlook97 Addressbook

    I'm not sure there's a thing like Addresslist, but you can use the contacts.

    Dim myOlApp as Object
    Dim myNameSpace as Object
    Dim myContacts as Object
    Dim myContact as Object
    Dim i as Integer

    set myOlApp = CreateObject("Outlook.Application")
    set myNameSpace = myOlApp.GetNamespace("MAPI")
    set myContacts = myNameSpace.GetDefaultFolder(olFolderContacts)

    for t = 1 to myContacts.Items.Count
    MsgBox myContacts.Items(t).Email1Address
    next t



    Other things you can use in stead of Email1Address are things like BusinessFaxNumber, HomePhoneNumber, Birthday and a whole bunch of other stuff (to much to list)

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Mar 2000
    Location
    Sheffield, UK
    Posts
    52

    Re: Outlook97 Addressbook

    Cheers Cakkie

    Half the battle won but I'm after a folder that is not Contacts but the Global Address List.

    Any Ideas?

    Cheers

    Rob


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured