Background:
VS 2015 - VB Windows Form Application
SQL Server 2008
Outlook PRO 2016
I want to read my Outlook contacts (global address list) and put them in a datagridview or combo box. I have found some routines on the web but they do no work. I found this one but I get an empty combobox. What is wrong?
Thanks in advance for your help.
VS 2015 - VB Windows Form Application
SQL Server 2008
Outlook PRO 2016
I want to read my Outlook contacts (global address list) and put them in a datagridview or combo box. I have found some routines on the web but they do no work. I found this one but I get an empty combobox. What is wrong?
Thanks in advance for your help.
Code:
Imports System.Reflection Imports Microsoft.Office.Interop Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim objOutlook As Microsoft.Office.Interop.Outlook._Application 'Outlook Namespace will be current session Dim objNS As Microsoft.Office.Interop.Outlook._NameSpace 'Initialise objects created in Form Load objOutlook = New Microsoft.Office.Interop.Outlook.Application() objNS = objOutlook.Session 'Get the Contact folder Dim objAddressList As Microsoft.Office.Interop.Outlook.MAPIFolder objAddressList = objNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts) 'Get all the contacts Dim objItems As Microsoft.Office.Interop.Outlook.Items = objAddressList.Items Dim objContact As Microsoft.Office.Interop.Outlook.ContactItem For j = 1 To objItems.Count If TypeOf (objContact) Is Microsoft.Office.Interop.Outlook.ContactItem Then objContact = objItems(j) Me.ComboBox1.Items.Add(objContact.Email1Address) End If Next 'clear memory objContact = Nothing objItems = Nothing objAddressList = Nothing End Sub End Class