How to: Programmatically Add an Entry to Outlook Contacts

 

This example creates a new contact and enters data into the new contact.

Applies to: The information in this topic applies to VSTO add-in projects for Outlook. For more information, see Features Available by Office Application and Project Type.

        private void AddContact()
        {
            Outlook.ContactItem newContact = (Outlook.ContactItem)
                this.Application.CreateItem(Outlook.OlItemType.olContactItem);
            try
            {
                newContact.FirstName = "Jo";
                newContact.LastName = "Berry";
                newContact.Email1Address = "somebody@example.com";
                newContact.CustomerID = "123456";
                newContact.PrimaryTelephoneNumber = "(425)555-0111";
                newContact.MailingAddressStreet = "123 Main St.";
                newContact.MailingAddressCity = "Redmond";
                newContact.MailingAddressState = "WA";
                newContact.Save();
                newContact.Display(true);
            }
            catch
            {
                MessageBox.Show("The new contact was not saved.");
            }
        }

Working with Contact Items
How to: Programmatically Create Appointments
How to: Programmatically Access Outlook Contacts
How to: Programmatically Search for an E-Mail Address in Contacts

Show: