SPMeeting.Add method (String, String, UInt32, String, String, String, String, String, Boolean, Int16)

Adds a meeting instance to the current Meeting Workspace site.

Namespace:  Microsoft.SharePoint.Meetings
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Function Add ( _
    organizer As String, _
    uid As String, _
    sequence As UInteger, _
    dateStamp As String, _
    title As String, _
    location As String, _
    dateStart As String, _
    dateEnd As String, _
    nonGregorian As Boolean, _
    <OutAttribute> ByRef nMeetingCount As Short _
) As Integer
'Usage
Dim instance As SPMeeting
Dim organizer As String
Dim uid As String
Dim sequence As UInteger
Dim dateStamp As String
Dim title As String
Dim location As String
Dim dateStart As String
Dim dateEnd As String
Dim nonGregorian As Boolean
Dim nMeetingCount As Short
Dim returnValue As Integer

returnValue = instance.Add(organizer, _
    uid, sequence, dateStamp, title, location, _
    dateStart, dateEnd, nonGregorian, _
    nMeetingCount)
public int Add(
    string organizer,
    string uid,
    uint sequence,
    string dateStamp,
    string title,
    string location,
    string dateStart,
    string dateEnd,
    bool nonGregorian,
    out short nMeetingCount
)

Parameters

  • organizer
    Type: System.String

    A string that contains the e-mail address of the meeting organizer, specified as email_address@domain.ext. This parameter is used in delegate scenarios. If the meeting organizer is not a delegate, you can pass an empty string. In that case, the user who runs the application is considered to be the meeting organizer.

  • uid
    Type: System.String

    A string that contains a unique identifier (UID) for a calendar event, as specified by RFC 2445.

  • sequence
    Type: System.UInt32

    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 do not arrive in order. Updates with a lower-than-current sequence number are discarded.

  • dateStamp
    Type: System.String

    A 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'".

  • dateStart
    Type: System.String

    A string that represents the date and time that the meeting is scheduled to begin. 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'".

  • dateEnd
    Type: System.String

    A string that represents the date and time that the meeting is scheduled to end. The date and time must be later than dateStart. The value must be expressed as Coordinated Universal Time (UTC) in the format that is specified by ISO 8601, as follows: "yyyyMMdd'T'HHmmss'Z'".

  • nonGregorian
    Type: System.Boolean

    true if the calendar is set to a format other than Gregorian; otherwise, false.

  • nMeetingCount
    Type: System.Int16

    A reference to a variable that will receive the total number of meeting instances that are associated with the current Meeting Workspace site.

Return value

Type: System.Int32
The instance ID of the meeting.

Remarks

The Add method creates a new meeting instance in the Meeting Workspace site. An appointment is not added to the SharePoint Foundation calendar.

Examples

The following example is a console application that creates a Meeting Workspace site and adds a meeting instance to the site.

Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Meetings

Module ConsoleApp
   Sub Main()
      Using site As SPSite = New SPSite("https://localhost")
         Using web As SPWeb = site.OpenWeb()

            ' Set up meeting parameters.
            Dim dtStart As DateTime = DateTime.Now.AddDays(6)
            Dim stamp As String = ISO8601BasicDate(DateTime.Now)
            Dim startTime As String = ISO8601BasicDate(dtStart)
            Dim endTime As String = ISO8601BasicDate(dtStart.AddHours(1))

            Dim title As String = "Test Sharepoint"
            Dim location As String = "Your office"
            Dim organizer As String = String.Empty
            Dim uid As String = Guid.NewGuid().ToString("N")
            Dim sequence As System.UInt32 = 0

            ' Create an output variable.
            Dim meetingCount As Short

            ' Create a Meeting Workspace site.
            Dim mwsWeb As SPWeb = CreateWorkspace(web, "Test", "Test Workspace", "A test workspace", "MPS#0")

            ' Get the meeting information for the workspace.
            Dim meetingInfo As SPMeeting = SPMeeting.GetMeetingInformation(mwsWeb)

            ' Add the meeting.
            Dim instanceID As Integer = meetingInfo.Add(organizer, uid, sequence, stamp, _
                                                        title, location, startTime, endTime, _
                                                        False, meetingCount)
            ' Clean up.
            mwsWeb.Dispose()

            ' Print the URL and number of meetings.
            Dim url As String = mwsWeb.Url + "?InstanceID=" + instanceID.ToString()
            Console.WriteLine(url)
            Console.WriteLine("Meeting count = {0}", meetingCount)

         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   End Sub

   Function CreateWorkspace(ByRef webSite As SPWeb, ByVal url As String, _
                            ByVal title As String, ByVal description As String, _
                            ByVal template As String) As SPWeb
      Dim mws As SPWeb = Nothing
      Try
         mws = webSite.Webs.Add(url, title, description, _
                                CType(webSite.Locale.LCID, System.UInt32), template, _
                                False, False)
      Catch
         If SPMeeting.IsMeetingWorkspaceWeb(webSite.Webs(url)) Then
            mws = webSite.Webs(url)
         End If
      End Try
      Return mws
   End Function

   Function ISO8601BasicDate(ByVal dt As DateTime) As String
      Dim format As String = "yyyyMMdd'T'HHmmss'Z'"
      Dim dtUTC As DateTime = dt.ToUniversalTime()
      Return dtUTC.ToString(format, System.Globalization.DateTimeFormatInfo.InvariantInfo)
   End Function

End Module
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Meetings;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite site = new SPSite("https://localhost"))
         {
            using (SPWeb web = site.OpenWeb())
            {
               // Define meeting parameters.
               DateTime dtStart = DateTime.Now.AddDays(5);
               string stamp = ISO8601BasicDate(DateTime.Now);
               string startTime = ISO8601BasicDate(dtStart);
               string endTime = ISO8601BasicDate(dtStart.AddHours(1));
               string title = "Test Sharepoint";
               string location = "Your office";
               string organizer = String.Empty;
               uint sequence = 0;
               string uid = Guid.NewGuid().ToString("N");

               // Create an output variable.
               short meetingCount;

               // Create a Meeting Workspace site.
               SPWeb mwsWeb = CreateWorkspace(web, "Test", "Test Workspace", "A test workspace", "MPS#0");

               // Get the meeting information for the workspace.
               SPMeeting meetingInfo = SPMeeting.GetMeetingInformation(mwsWeb);

               // Add the meeting.
               try
               {
                  int instanceID = meetingInfo.Add(organizer, uid, sequence,
                                               stamp, title, location,
                                               startTime, endTime, false,
                                               out meetingCount);

                  // Print the URL and number of meetings.
                  string url = mwsWeb.Url + "?InstanceID=" + instanceID.ToString();
                  Console.WriteLine(url);
                  Console.WriteLine("Meeting count = {0}", meetingCount);
               }
               catch (SPException ex)
               {
                  Console.WriteLine(ex.Message);
               }

               // Clean up.
               mwsWeb.Dispose();
            }
         }
         Console.Write("\nPress ENTER to continue...");
         Console.ReadLine();
      }

      static SPWeb CreateWorkspace(SPWeb webSite, string url, string title,
                                   string description, string template)
      {
         SPWeb mws = null;
         try
         {
            mws = webSite.Webs.Add(url, title, description,
                                   (uint)webSite.Locale.LCID, template,
                                   false, false);
         }
         catch (SPException) // A site of that name already exists.
         {
            if (SPMeeting.IsMeetingWorkspaceWeb(webSite.Webs[url]))
               mws = webSite.Webs[url];
         }
         return mws;
      }

      static string ISO8601BasicDate(DateTime dt)
      {
         string format = "yyyyMMdd'T'HHmmss'Z'";
         DateTime dtUTC = dt.ToUniversalTime();
         return dtUTC.ToString(format, System.Globalization.DateTimeFormatInfo.InvariantInfo);
      }

   }
}

See also

Reference

SPMeeting class

SPMeeting members

Add overload

Microsoft.SharePoint.Meetings namespace

MeetingCount

InstanceId

Update(String, UInt32, String, String, String, String, String, Boolean)