Create a Business Project linked to a Primary Account

You can create a Business Project object and link it to one or more Account objects, but the business project can have only one primary Account. If linked to an Account, the History section of the Account form displays details of the business project and the Link To field on the Business Project form displays the Account name.

The following C# and Visual Basic for Applications (VBA) examples show how to create a new business project and link it with a new Account object.

C#

  private void CreateBusinessProjectWithAccount()
        {

            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["Accounts"];
            
            Outlook.ContactItem newAccount =
            (Outlook.ContactItem)accounts.Items.Add("IPM.Contact.BCM.Account");

            newAccount.FullName = "Wide World Importers";
            newAccount.FileAs = "WWImporters";
            newAccount.Save();

            string accountEntryID = newAccount.EntryID;

            Outlook.Folder projects = (Outlook.Folder)bcmRootFolder.Folders["Business Projects"];
            Outlook.TaskItem newProject =
            (Outlook.TaskItem)projects.Items.Add("IPM.Task.BCM.Project");
            newProject.Subject = "Sales Project with Wide World Importers";

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

            newProject.Save();

        }


VBA

  Sub CreateBusinessProjectWithAccount()

   Dim olApp As Outlook.Application
   Dim objNS As Outlook.NameSpace
   Dim olFolders As Outlook.Folders
   Dim bcmRootFolder As Outlook.Folder
   Dim bcmAccountsFldr As Outlook.Folder
   Dim existAcct As Outlook.ContactItem
   Dim newProject As Outlook.TaskItem
   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 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

   newProject.Save

   Set newProject = Nothing
   Set existAcct = Nothing
   Set bcmAccountsFldr = Nothing
   Set bcmRootFolder = Nothing
   Set olFolders = Nothing
   Set objNS = Nothing
   Set olApp = Nothing

End Sub

See Also

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