This Article show that how to access Outlook Contact list
For better understanding we take an example, in this example there is one window form with datagridview. We have to show all contacts in this datagridview, somthing like this:
Add referance of Microsoft.Office.Interop.Outlook library(example is using Microsoft.Office.Interop.Outlook 12.0)
Add one DatagridView and one button on form1.
And Declare:
Microsoft.Office.Interop.Outlook.Items OutlookItems; Microsoft.Office.Interop.Outlook.Application outlookObj; MAPIFolder Folder_Contacts;
Work on Form1:
private void Form1_Load(object sender, EventArgs e) { Microsoft.Office.Interop.Outlook.Application outlookObj = new Microsoft.Office.Interop.Outlook.Application(); MAPIFolder Folder_Contacts = (MAPIFolder)outlookObj.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts); OutlookItems = Folder_Contacts.Items; for (int i = 0; i < oItems.Count; i++) { Microsoft.Office.Interop.Outlook.ContactItem contact = (Microsoft.Office.Interop.Outlook.ContactItem)OutlookItems[i + 1]; dataGridView1.Rows.Add(); if (contact.FirstName != null) { dataGridView1.Rows[i].Cells[0].Value = contact.FirstName; } else { dataGridView1.Rows[i].Cells[0].Value = ""; } if (contact.LastName != null) { dataGridView1.Rows[i].Cells[1].Value = contact.LastName; } else { dataGridView1.Rows[i].Cells[1].Value = ""; } if (contact.LastName != null) { dataGridView1.Rows[i].Cells[3].Value = contact.LastName; } else { dataGridView1.Rows[i].Cells[3].Value = ""; } if (contact.Email1Address != null) { dataGridView1.Rows[i].Cells[3].Value = contact.Email1Address; } else { dataGridView1.Rows[i].Cells[3].Value = ""; } } }