Select a Business Project
To select an Business Project object, use the Collection.Find method to select an item from the MAPI Folder. The Find method accepts as input a String query and filters items based on the query. If there are more than one items matching the query, only the first match is returned.
The following C# and Visual Basic for Applications (VBA) examples show how to select an existing Business Project object.
C#
private void SelectBusinessProject()
{
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)
{
Console.WriteLine("Project Found");
}
else
{
Console.WriteLine("Project Not Found");
}
Console.ReadLine();
}
VBA
Sub SelectBusinessProject()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim bcmRootFolder As Outlook.Folder
Dim olFolders As Outlook.Folders
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
MsgBox ("Project selected successfully")
Else
MsgBox ("No Project found with the name of 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 | Edit a Business Project | Delete a Business Project | 2007 Office System: Updated Developer Content