Share via


Delete a Business Project

Outlook Developer Reference
Delete a Business Project

To remove a Business Project object programmatically, first select the business project and then call the Delete method. The following C# and Visual Basic for Applications (VBA) examples show how to delete a Business Project object.

  private void DeleteBusinessProject()
{ 

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.Delete(); }

else { Console.WriteLine("Project Not Found"); }

}

  Sub DeleteBusinessProject() 

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.Delete 

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 | Edit a Business Project | Office Developer Center: Outlook 2007