• Reading Outlook e-mail addresses (Visual Basic 6.0)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Reading Outlook e-mail addresses (Visual Basic 6.0)

    Author
    Topic
    #365245

    This, I’m sure, is a simple thing to do, but despite having tons of samples, I can’t seem to find an answer. I’d like to be able to display my list of contacts inside VB, letting the user pick a name. Once the name is selected, use that e-mail address in the program.
    My test program has been able to read a couple of addresses, but they don’t seem to be from the Contacts folder.
    Does anyone have any sample code that would demonstrate this?

    Viewing 0 reply threads
    Author
    Replies
    • #563192

      This looks like the code that you need, but there’s no VB on my current machine, so I can’t test it out. Reply back if you have problems; tomorrow, I’ll be on a VB machine. Don’t forget to add a reference to Outlook via the Project | References menu. HTH –Sam

      • #563368

        I tried that, but kept getting errors. However, it did point me in the right direction for some research. I found this subroutine which fills the bill:

        Private Sub RetrieveOutlookList()
        Set olApp = New Outlook.Application
        Set olNS = olApp.GetNamespace(“MAPI”)
        dlgAddress.Combo1.Text = “or select an e-mail address from this box.”
        For Each olAL In olNS.AddressLists
        For Each olAE In olAL.AddressEntries
        dlgAddress.Combo1.AddItem olAE.Name & “(” & olAE.Address & “)”
        Next
        Next
        End Sub

        You still have to make a reference to Outlook (like before) and Outlook needs to be running.

        Brian A.

    Viewing 0 reply threads
    Reply To: Reading Outlook e-mail addresses (Visual Basic 6.0)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: