Create a Business Contact

The following C# and Visual Basic for Applications (VBA) examples show how to create a new Business Contact object and assign to it some basic information about the Business Contact, such as the Business Contact name, business address, telephone, and e-mail address.

C#

  private void CreateBusinessContact()
        {

            Outlook.ApplicationClass _app = new Outlook.ApplicationClass();
            Outlook.Application olApp = (Outlook.Application)_app;
            Outlook.NameSpace olNameSpace = _app.GetNamespace("MAPI");
            Outlook.Folders folders = olNameSpace.Session.Folders;
            Outlook.Folder bcmRootFolder = (Outlook.Folder)folders["Business Contact Manager"];
            Outlook.Folder accounts = (Outlook.Folder)bcmRootFolder.Folders["Business Contacts"];
            Outlook.UserProperty userProp;

            Outlook.ContactItem newContact = (Outlook.ContactItem)accounts.Items.Add("IPM.Contact.BCM.Contact");

            newContact.FullName = "John Smith";
            newContact.FileAs = "John Smith";

            newContact.BusinessAddressStreet = "4567, Main Street, Suite# J 225";
            newContact.BusinessAddressCity = "Redmond";
            newContact.BusinessAddressState = "Washington";
            newContact.BusinessAddressPostalCode = "07457";
            newContact.BusinessAddressCountry = "United States";

            newContact.BusinessTelephoneNumber = "+1-425-555-0100";
            newContact.Email1Address = "someone@example.com";
            newContact.WebPage = " http://www.wideworldimporters.com/jsmith";

            if (newContact.UserProperties["Do Not Call"] == null)
            {
                userProp = newContact.UserProperties.Add("Do Not Call", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olYesNo, false, false);
                userProp.Value = true;
            }

            newContact.Save();
       }


VBA

  Sub CreateBusinessContact() 

   Dim olApp As Outlook.Application
   Dim objNS As Outlook.NameSpace
   Dim bcmRootFolder As Outlook.Folder
   Dim olFolders As Outlook.Folders
   Dim bcmContactsFldr As Outlook.Folder
   Dim newContact As Outlook.ContactItem 

   Set olApp = CreateObject("Outlook.Application")
   Set objNS = olApp.GetNamespace("MAPI")
   Set olFolders = objNS.Session.Folders
   Set bcmRootFolder = olFolders("Business Contact Manager")
   Set bcmContactsFldr = bcmRootFolder.Folders("Business Contacts") 
 
   Set newContact = bcmContactsFldr.Items.Add("IPM.Contact.BCM.Contact")
   newContact.FullName = "John Smith"
   newContact.FileAs = "John Smith"
   newContact.Email1Address = "someone@example.com"
   newContact.Save 

   Set newContact = Nothing
   Set bcmContactsFldr = Nothing
   Set bcmRootFolder = Nothing
   Set olFolders = Nothing
   Set objNS = Nothing
   Set olApp = Nothing 

End Sub  

See Also

Select a Business Contact | Edit a Business Contact | Delete a Business Contact | Link Business Contacts to an Account | Create an Opportunity linked to a Business Contact | Create a Business Project linked to a Primary Business Contact | 2007 Office System: Updated Developer Content