Associated Contacts Property

Gets or sets a String array value representing the Business Contact names linked to a Business Project. The attribute for this value is read/write.

expression**.ItemProperties["Associated Contacts"].Value**

expression   A variable that represents a Business Project object.

Example

The following C# and Visual Basic for Applications (VBA) examples show how to create and associate a Business Contact to a Business Project.

C#

  private void CreateAssociatedBusinessContactsInBusinessProject()
        {
            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 contacts = (Outlook.Folder)bcmRootFolder.Folders["Business Contacts"];

            Outlook.Folder accounts = (Outlook.Folder)bcmRootFolder.Folders["Accounts"];
            Outlook.UserProperty userProp;

            Outlook.ContactItem newAccount = (Outlook.ContactItem)accounts.Items.Add("IPM.Contact.BCM.Account");
            newAccount.FullName = "Wide World Importers";
            newAccount.FileAs = "WWImporters";
            newAccount.Save();

            Outlook.Folder projects = (Outlook.Folder)bcmRootFolder.Folders["Business Projects"];

            Outlook.TaskItem newProject = (Outlook.TaskItem)projects.Items.Add("IPM.Task.BCM.Project");
            newProject.Subject = "Sales Opp with John Smith";

            if (newProject.UserProperties["Parent Entity EntryID"] == null)
            {
                userProp = newProject.UserProperties.Add("Parent Entity EntryID", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, false, false);
                userProp.Value = newAccount.EntryID;
            }

            newProject.Save();

            Outlook.ContactItem newContact1 = (Outlook.ContactItem)contacts.Items.Add("IPM.Contact.BCM.Contact");
            newContact1.FullName = "John Smith";
            newContact1.FileAs = "John";
            newContact1.Save();

            Outlook.ContactItem newContact2 = (Outlook.ContactItem)contacts.Items.Add("IPM.Contact.BCM.Contact");
            newContact2.FullName = "Liz Keyser";
            newContact2.FileAs = "Liz Keyser";
            newContact2.Save();

            string[] array = new string[2];
            array[0] = newContact1.EntryID;
            array[1] = newContact2.EntryID;

            if (newProject.UserProperties["Associated Contacts"] == null)
            {
                userProp = newProject.UserProperties.Add("Associated Contacts", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olKeywords, false, false);
                userProp.Value = newAccount.EntryID;
            }

            newProject.ItemProperties["Associated Contacts"].Value = array;
            newProject.Save();
        } 

VBA

  Sub CreateAssociatedBusinessContactsInBusinessProject()

    Dim olApp As Outlook.Application
    Dim objNS As Outlook.NameSpace

    Dim bcmRootFolder As Outlook.Folder
    Dim olFolders As Outlook.Folders
    Dim bcmAccountsFldr As Outlook.Folder
    Dim bcmOppFolder As Outlook.Folder
    Dim bcmHistoryFolder As Outlook.Folder
    Dim bcmContactsFldr As Outlook.Folder

    Dim existAcct As Outlook.ContactItem
    Dim newProject As Outlook.TaskItem
    Dim newContact As Outlook.ContactItem
    Dim newContact1 As Outlook.ContactItem

    Dim newAppItem As Outlook.AppointmentItem
    Dim newHistoryTaskItem As Outlook.JournalItem
    Dim newBusinessNote As Outlook.JournalItem
    Dim newPhoneLog As Outlook.JournalItem
    Dim newTaskItem As Outlook.TaskItem
    Dim userProp As Outlook.UserProperty

    Set olApp = CreateObject("Outlook.Application")
    Set objNS = olApp.GetNamespace("MAPI")
    Set olFolders = objNS.Session.Folders

    Set bcmRootFolder = olFolders("Business Contact Manager")
    Set bcmAccountsFldr = bcmRootFolder.Folders("Accounts")
    Set bcmProjFolder = bcmRootFolder.Folders("Business Projects")
    Set bcmOppFolder = bcmRootFolder.Folders("Opportunities")

    Set newAcct = bcmAccountsFldr.Items.Add("IPM.Contact.BCM.Account")
    newAcct.FullName = "Wide World Importers"
    newAcct.FileAs = "Wide World Importers"
    newAcct.Email1Address = "someone@example.com"
    newAcct.Save

    Set newProject = bcmProjFolder.Items.Add("IPM.Task.BCM.Project")
    newProject.Subject = "Project For Wide World Importers to enter into Retail Field"
    
    If (newProject.UserProperties("Parent Entity EntryID") Is Nothing) Then
        Set userProp = newProject.UserProperties.Add("Parent Entity EntryID", olText, False, False)
        userProp.Value = newAcct.EntryID
    End If
    
    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 newContact1 = bcmContactsFldr.Items.Add("IPM.Contact.BCM.Contact")
    newContact1.FullName = "John Smith1"
    newContact1.FileAs = "John Smith1"
    newContact1.Email1Address = "someone@example.com"
    newContact1.Save
    
    
    Dim contactArray(1) As String
    contactArray(0) = newContact.EntryID
    contactArray(1) = newContact1.EntryID
    
    If (newProject.UserProperties("Associated Contacts") Is Nothing) Then
        Set userProp = newProject.UserProperties.Add("Associated Contacts", olKeywords, False, False)
        userProp.Value = contactArray
    End If
    
    newProject.ItemProperties("Associated Contacts").Value = contactArray
    newProject.Save
    
    Set newProject = Nothing
    Set newBusinessNote = Nothing
    Set newAppItem = Nothing
    Set newPhoneLog = Nothing
    Set newHistoryTaskItem = Nothing
    Set newTaskItem = Nothing
    Set newProject = Nothing
    Set existAcct = Nothing
    Set bcmAccountsFldr = Nothing
    Set olFolders = Nothing
    Set bcmRootFolder = Nothing
    Set objNS = Nothing
    Set olApp = Nothing

End Sub

Remarks

The Outlook UserProperty type is olKeywords.

See Also

2007 Office System: Updated Developer Content