Results 1 to 2 of 2

Thread: No...

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    I do this from my local drive, no network.
    I have added the reference 'Micosoft outlook 9.0 object library' to the project and I'm using following code:

    Private Sub cmdShow_Click()

    On Error Resume Next
    Dim i As Integer
    With lstEmails
    For i = 0 To .ListCount - 1
    If .Selected(i) Then
    MsgBox .ListIndex(i)
    End If
    End With

    End Sub

    Private Sub Form_Load()

    'Get the outlook instance:

    Dim moMail As Object
    Dim loNameSpace As Object
    Dim loNameAddresses As Object
    Dim loAddresses As Object
    Dim loAddressList As Object

    Set moMail = New Outlook.Application
    Dim moAddresses As Outlook.AddressLists

    Set loNameSpace = moMail.GetNamespace("MAPI")
    Set loAddresses = loNameSpace.AddressLists("Contacts")
    Set loAddressList = loAddresses.AddressEntries

    'Add -> lstEmails:
    For i = 1 To loAddressList.Count
    lstEmails.AddItem loAddressList.Item(i).Address
    Next i

    End Sub

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Scottsdale, Arizona, USA
    Are you trying to add all names to the listbox??? If that's the case, here's what you can do:
    Private Sub Command1_Click()
        Dim i As Integer
        Dim objMail As New Outlook.Application
        Dim objAddList As Outlook.AddressList
        Dim objNameSpace As Outlook.NameSpace
        Dim objAddEntCol As Outlook.AddressEntries
        Dim objAddEntry As Outlook.AddressEntry
        Set objNameSpace = objMail.GetNamespace("MAPI")
        Set objAddList = objNameSpace.AddressLists("Contacts")
        Set objAddEntCol = objAddList.AddressEntries
        Set objAddEntry = objAddEntCol.GetFirst
        Do Until objAddEntry Is Nothing
            List1.AddItem objAddEntry.Name
            Set objAddEntry = objAddEntCol.GetNext
        Set objAddEntCol = Nothing
        Set objAddEntry = Nothing
        Set objAddList = Nothing
        Set objList = Nothing
        Set objNameSpace = Nothing
    End Sub
    [Edited by Serge on 11-21-2000 at 06:32 PM]

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