Is there a way to get all contacts id's from outlook 2013 or 2007 to datagridview or combobox.collection list.

Thanks

Yes. There are a number of APIs out there, including one that comes with Office, that will support this functionality.

Add reference to "Microsoft Outlook xx.x Object Library" (where xx.x = 14.0, 12.0, etc):
* Click "Project"
* Select "Add Reference"
* Click "COM"
* Select "Microsoft Outlook 14.0 Object Library"

Add Imports statement:

  • Imports Outlook = Microsoft.Office.Interop.Outlook;

getContacts:

Private Sub getContacts()

    'create new instance of Outlook.Application
    Dim outlookApp As Outlook.Application = New Outlook.Application()

    'create new instance of Outlook.MAPIFolder
    Dim outlookMapiFolder As Outlook.MAPIFolder = Nothing

    'create new instance of Outlook.Items
    Dim outlookItems As Outlook.Items = Nothing

    'set outlookMapiFolder to Contacts folder
    outlookMapiFolder = outlookApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

    'get items from contacts
    outlookItems = outlookMapiFolder.Items


    For i As Integer = 0 To outlookItems.Count - 1

        Dim contact As Outlook.ContactItem = outlookItems(i + 1)


        Dim entryId As String = contact.EntryID
        Dim fullName As String = contact.FullName
        Dim companyName As String = contact.CompanyName
        Dim email1Address As String = contact.Email1Address
        Dim email1AddressType As String = contact.Email1AddressType
        Dim businessTelephoneNumber As String = contact.BusinessTelephoneNumber
        Dim homeTelephoneNumber As String = contact.HomeTelephoneNumber
        Dim mobileTelephoneNumber As String = contact.MobileTelephoneNumber

        'add any additional entries that you want to retrieve



        'add entryId and fullName to dataGridView1
        'where DataGridView1 is a DataGridView with
        'columns "entryId" and "fullName"
        DataGridView1.Rows.Add(entryId, fullName)

    Next
End Sub

Resources:
Adapted from: Get Outlook Contacts in to C# form based Application

Outlook Object Model Overview

thanks

i want to get contacts from Global Address List

i just want to retrive contact list no modification to Global Address List.

how to specify Global Address List folder name.
thanks

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.