Use An Addresse From Outlook Address Book Before Send

  • I've been trying to search in every way possible on Ozgrid but I can't seem to find the answer...


    I'm trying to have a popup with a dropdown that populates with names from the Outlook address book.


    Additionally, I'd like the user to be able to select multiple names from this list that they'd like to send the attached workbook.


    Again, I've tried to find this for I'm sure that this ground has been covered, but I cannot for whatever reason.


    TIA


    Phil

  • Re: Pick An Addresses From Outlook Address Book Before Send


    In order to select multiple email addresses you will need to use a listbox.
    Add listbox to a userform
    [vba]
    Private Sub UserForm_Initialize()
    '
    ' Requires reference to MS Outlook library
    '
    Dim olApp As Outlook.Application
    Dim olNamespace As Outlook.Namespace
    Dim olItem As Outlook.AddressEntry
    Dim olAddressList As Outlook.AddressList
    Dim olAddressEntry As Outlook.AddressEntry

    With ListBox1
    .ColumnCount = 2
    .ListStyle = fmListStyleOption
    .MultiSelect = fmMultiSelectExtended
    End With

    Set olApp = GetObject("", "Outlook.application")
    Set olNamespace = olApp.GetNamespace("MAPI")

    For Each olAddressList In olNamespace.AddressLists
    For Each olAddressEntry In olAddressList.AddressEntries
    ListBox1.AddItem olAddressEntry.Name
    ListBox1.List(ListBox1.ListCount - 1, 1) = olAddressEntry.Address
    Next
    Next

    End Sub
    [/vba]


    This will do all you address books/contacts.

    [h4]Cheers
    Andy
    [/h4]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!