Edit a Business Project
To edit a Business Project object programmatically, do the following:
- Select the object.
- Assign new values to those properties that you want to modify.
- Invoke the Save method on the object to save the changes.
The following C# and Visual Basic for Applications (VBA) examples show how to edit a Business Project object.
C#
private void EditBusinessProject()
{
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 projectsFolder = (Outlook.Folder)bcmRootFolder.Folders["Business Projects"];
string strQuery = "[Subject] = 'Sales Project with Wide World Importers'";
Outlook.TaskItem projectItem = (Outlook.TaskItem)projectsFolder.Items.Find(strQuery);
if (projectItem != null)
{
projectItem.Categories = "Blue";
projectItem.Save();
}
else
{
Console.WriteLine("Project Not Found");
}
}
VBA
Sub UpdateBusinessProject()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim olFolders As Outlook.Folders
Dim bcmRootFolder As Outlook.Folder
Dim bcmProjectsFolder As Outlook.Folder
Dim existingProject 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 bcmProjectsFolder = bcmRootFolder.Folders("Business Projects")
Set existingProject = bcmProjectsFolder.Items.Find("[Subject] = 'Project For Wide World Importers to enter into Retail Field'")
If Not TypeName(existingProject) = "Nothing" Then
existingProject.Categories = "Blue"
existingProject.Save
Else
MsgBox ("No Project found with name - Wide World Importers")
End If
Set existingProject = Nothing
Set bcmProjectsFolder = Nothing
Set bcmRootFolder = Nothing
Set olFolders = Nothing
Set objNS = Nothing
Set olApp = Nothing
End Sub
See Also
Create a Business Project linked to a Primary Account | Create a Business Project linked to a Primary Business Contact | Select a Business Project | Delete a Business Project | 2007 Office System: Updated Developer Content