Share via


Using the Windows SharePoint Services Object Model

The following code examples show how to use the Microsoft® Windows® SharePoint™ Services object model to work with Meeting Workspace sites.

Identifying existing Meeting Workspace sites

The following code example prints the names of the Meeting Workspace sites that exist on the top-level site on the server.

[C#]

SPGlobalAdmin globAdmin = new SPGlobalAdmin();
System.Uri uri = new System.Uri("http://server_name");
SPVirtualServer vServer = globAdmin.OpenVirtualServer(uri);
SPSite TargetSite = vServer.Sites["http://server_name"];
SPWeb RootWeb = TargetSite.OpenWeb("/");
SPWebCollection spRootWebChildren = RootWeb.Webs;
for (int i =0; i<spRootWebChildren.Count;i++)
 {
 if(spRootWebChildren[i].WebTemplateId == (int) SPWebTemplate.WebTemplate.Meetings)
  {
   Console.WriteLine(spRootWebChildren[i].Name.ToString());
  }
 }
}

Deleting existing Meeting Workspace sites

The following code example deletes the Meeting Workspace site with the name "testmws" from the top-level site on the server.

[C#]

SPGlobalAdmin globAdmin = new SPGlobalAdmin();
System.Uri uri = new System.Uri("http://server_name");
SPVirtualServer vServer = globAdmin.OpenVirtualServer(uri);
SPSite TargetSite = vServer.Sites["http://server_name"];
SPWeb RootWeb = TargetSite.OpenWeb("/");
SPWebCollection spRootWebChildren = RootWeb.Webs;
for (int i =0; i<spRootWebChildren.Count;i++)
 {
 if(spRootWebChildren[i].WebTemplateId == (int) SPWebTemplate.WebTemplate.Meetings)
  {
  if(spRootWebChildren[i].Name=="testmws")
  spRootWebChildren.Delete("testmws");
  }
 }
}