title: Get Outlook contacts into C# form-based application
body: <p>I have tried to get the contacts of Outlook contacts into C#, but it is not working. I have used the Microsoft Outlook 12.0 Object Library. I want to show the data in richtextbox or gridview.</p>
  
  <p>The code is pasted below. Please let me know what I should do there.</p>
  
  <pre><code>    private void getContacts_Click(object sender, EventArgs e)
      {
          // Obtain an instance of the Outlook application
          Outlook.Application app = new Outlook.ApplicationClass();
  
          // Access the MAPI namespace
          Outlook.NameSpace ns = app.GetNamespace("MAPI");
  
          // Get the user's default contacts folder
          Outlook.MAPIFolder contacts =
          ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
  
          // Iterate through each contact
          for (int i = 1; i &lt; contacts.Items.Count + 1; i++)
          {
              // Get a contact
              Outlook.ContactItem contact =
              (Outlook.ContactItem)contacts.Items[i];
              richTextBox1.Text += contact.FullName + " (" +
              contact.BusinessTelephoneNumber + ")" + Environment.NewLine;
              Application.DoEvents();
          }
      }
  }
  </code></pre>