SPMeeting.Cancel Method
Removes the association between a meeting and a Meeting Workspace site.
Namespace: Microsoft.SharePoint.Meetings
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Sub Cancel ( _
uid As String, _
recurrenceID As UInteger, _
sequence As UInteger, _
dateStamp As String, _
cancelMeeting As Boolean _
)
'Usage
Dim instance As SPMeeting
Dim uid As String
Dim recurrenceID As UInteger
Dim sequence As UInteger
Dim dateStamp As String
Dim cancelMeeting As Boolean
instance.Cancel(uid, recurrenceID, sequence, _
dateStamp, cancelMeeting)
public void Cancel(
string uid,
uint recurrenceID,
uint sequence,
string dateStamp,
bool cancelMeeting
)
Parameters
uid
Type: System.StringA string that contains a unique identifier (UID) for a calendar event as specified by RFC 2445. For a recurring meeting, each meeting instance shares a common UID. To distinguish between instances of a recurring meeting, each instance is also assigned a RecurrenceID.
recurrenceID
Type: System.UInt32A value that identifies an instance of a recurring meeting. For a single-instance meeting, pass 0. For a recurring meeting, pass a value corresponding to the date of the meeting instance in the form YYYYMMDD. For example, the value that identifies an instance of a recurring meeting scheduled for May 1, 2010 is 20100501.
sequence
Type: System.UInt32A value that denotes the revision sequence number as specified by RFC 2445. Sequence numbers begin at zero and are incremented with each revision. The sequence number is used to determine the order of updates in case they arrive out of order. Updates with a lower-than-current sequence number are discarded.
dateStamp
Type: System.StringA string that represents the current date and time. The date and time must be expressed as Coordinated Universal Time (UTC) in the format that is specified by ISO 8601, as follows: "yyyyMMdd'T'HHmmss'Z'".
cancelMeeting
Type: System.Booleantrue if you want to delete a meeting.
Remarks
The Cancel method does not delete agenda items, documents, or other information associated with a meeting in the Meeting Workspace site.
Examples
The following example is a console application that enumerates all workspaces below the current Web site and, in each workspace, cancels every meeting that is scheduled for a time in the past.
Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Meetings
Module ConsoleApp
Sub Main()
Using siteCollection As SPSite = New SPSite("https://localhost")
Using webSite As SPWeb = siteCollection.RootWeb
' Construct a query to get meetings scheduled for dates in the past.
Dim ISO8601ExtendedFormat As String = DateTime.UtcNow.ToString("s")
Dim query As SPQuery = New SPQuery()
query.DatesInUtc = True
query.ViewXml = "<View><Query><Where>" + _
"<Lt><FieldRef Name='EventDate'/>" + _
"<Value Type='DateTime'>" + ISO8601ExtendedFormat + "</Value>" + _
"</Lt></Where></Query></View>"
' Get a collection of single-instance Meeting Workspace sites.
Dim mwWebs As SPWebCollection = _
SPMeeting.GetMeetingInformation(webSite).GetWorkspacesToLinkTo(False)
Dim workspace As SPWeb
For Each workspace In mwWebs
' Get the meeting information for this workspace.
Dim meeting As SPMeeting = SPMeeting.GetMeetingInformation(workspace)
' Get list items for past events.
Dim items As SPListItemCollection = workspace.Lists("Meeting Series").GetItems(query)
Dim item As SPListItem
For Each item In items
Dim uid As String = Convert.ToString(item("EventUID"))
Dim ISO8601BasicFormat As String = "yyyyMMdd'T'HHmmss'Z'"
Dim dateStamp As String = DateTime.UtcNow.ToString(ISO8601BasicFormat, _
System.Globalization.DateTimeFormatInfo.InvariantInfo)
Console.WriteLine("Canceling the {0} meeting that was scheduled for {1}.", _
item.Title, item("EventDate"))
Try
meeting.Cancel(uid, 0, 0, dateStamp, True)
Catch ex As SPException
Console.WriteLine("Cancellation failed. {0}", ex.Message)
End Try
Next
' Clean up
workspace.Dispose()
Next
End Using
End Using
Console.Write(vbCrLf + "Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Meetings;
namespace Example
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite siteCollection = new SPSite("https://localhost"))
{
using (SPWeb webSite = siteCollection.OpenWeb())
{
// Construct a query to get meetings scheduled for dates in the past.
string ISO8601ExtendedFormat = DateTime.UtcNow.ToString("s");
SPQuery query = new SPQuery();
query.DatesInUtc = true;
query.ViewXml = "<View><Query><Where>" +
"<Lt><FieldRef Name='EventDate'/>" +
"<Value Type='DateTime'>" + ISO8601ExtendedFormat + "</Value>" +
"</Lt></Where></Query></View>";
// Get a collection of single-instance Meeting Workspace sites.
SPWebCollection mwWebs =
SPMeeting.GetMeetingInformation(webSite).GetWorkspacesToLinkTo(false);
foreach (SPWeb workspace in mwWebs)
{
// Get the meeting information for this workspace.
SPMeeting meeting = SPMeeting.GetMeetingInformation(workspace);
// Get list items for past events.
SPListItemCollection items = workspace.Lists["Meeting Series"].GetItems(query);
foreach (SPListItem item in items)
{
string uid = Convert.ToString(item["EventUID"]);
string ISO8601BasicFormat = "yyyyMMdd'T'HHmmss'Z'";
string dateStamp = DateTime.UtcNow.ToString(ISO8601BasicFormat,
System.Globalization.DateTimeFormatInfo.InvariantInfo);
Console.WriteLine("Canceling the {0} meeting that was scheduled for {1}.",
item.Title, item["EventDate"]);
try
{
meeting.Cancel(uid, 0, 0, dateStamp, true);
}
catch (SPException ex)
{
Console.WriteLine("Cancellation failed. {0}", ex.Message);
}
}
// Clean up
workspace.Dispose();
}
}
}
Console.Write("\nPress ENTER to continue...");
Console.ReadLine();
}
}
}