Click here to Skip to main content
15,886,049 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Try
        ' Create an Outlook application.
        Dim oApp As Outlook._Application = New Outlook.Application()

        ' Get the MAPI namespace.
        Dim oNS As Outlook.NameSpace = oApp.Session

        ' Get the Global Address List.
        Dim oALs As Outlook.AddressLists = oNS.AddressLists
        Dim oGal As Outlook.AddressList = oALs.Item("Contacts")

        ' Get all the entries.
        Dim oEntries As Outlook.AddressEntries = oGal.AddressEntries
        Dim oEntry As Outlook.AddressEntry

        Dim i As Integer

        For i = 1 To oEntries.Count

            oEntry = oEntries.Item(i)
            ComboBox1.Items.Add(oEntry.Name)
        Next

    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try

End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    Try
        ' Create an Outlook application.
        Dim oApp As Outlook._Application = New Outlook.Application()

        ' Get the MAPI namespace.
        Dim oNS As Outlook.NameSpace = oApp.Session

        ' Get the Global Address List.
        Dim oALs As Outlook.AddressLists = oNS.AddressLists
        Dim oGal As Outlook.AddressList = oALs.Item("Contacts")


        ' Get all the entries.
        Dim oEntries As Outlook.AddressEntries = oGal.AddressEntries
        Dim oDL As Outlook.AddressEntry
        oDL = oEntries.Item(ComboBox1.SelectedItem.ToString)

        TextBox2.Text = oDL.GetContact.FullName

    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub


The problem is;

The ComboBox1.SelectedItem = the selected contact
The oDL = the next contact in ComboBox1 NOT the selected contact

Any help would be great Thanx
Tim
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900