Hello Everyone ,
How to send Real Meeting Request From Sharepoint 2010 article continues with part2
Here is the links for How to send Real Meeting Request From Sharepoint 2010 Series:
https://blog.bugrapostaci.com/2012/02/17/how-to-send-real-meeting-request-from-sharepoint-2010-part-1/
https://blog.bugrapostaci.com/2012/02/17/how-to-send-real-meeting-request-from-sharepoint-2010-part-2/
https://blog.bugrapostaci.com/2012/02/17/how-to-send-real-meeting-request-from-sharepoint-2010-part-3-deployment/
https://blog.bugrapostaci.com/2012/02/17/how-to-send-real-meeting-requests-from-sharepoint-2010-part4-usage/
Lets have a look for internally whats happening in a Meeting Workspace.

If you open a meeting workspace web with Sharepoint Manager 2010 you can brows all components in a basic meeting workspace template.
Some important list are Attendees , Meeting Serries , Workspace Pages ,
The Meeting Serries list contains Event information when you related a calender item with a meeting workspace instance. In this demo we have already attached two calender event this this meeting workpaced named “Scrum Meetings” . Every item has in Meeting Series an InstanceID so when you open a Event item and click linked workspace url
you can see this instanceID has been added end of this url . For example:
https://blog.bugrapostaci.com/scrummeetings?InstanceID=2
That means sharepoint sperates data according this Instance Parameter. As you noticed if you look carefully above image we have 6 attendees . This number is sum of all attendees count .But when you connect a workspace with an InstanceID and if you compare fallowing properties for an Attendees list.
SPList attendeesList = web.Lists[“Attendees”];
attendeesList.ItemCount is 6 : means all attendees count contains other meeting instances counts
attendeesList.Items.Count is 2 : meens this instance attendees count.
Sharepoint is differantiate the attendees data automatically and internally for which meeting workspace instance in use.
So be careful when you are working with in Meeting Workspaces on InstaceID property and differantiation of data according to this property.
Sharepoint Manager 2010 is a very useful tool when you programming with Sharepoint. You can use it with define Column Names and properties for serval objects in hiearchically.

But what if you dont want to use it , the powershell can also makes some help in this issue. For example if you want to learn which internal columns of an Meeting Series List item . you can get this information via powershell and write in a file in your drive like:
$Site = Get-SPList http://blog.bugrapostaci.com
$web = $site.OpenWeb(“ScrumMeetings”)
$mList = $web.Lists[“Meeting Series”]
$mList.Fields |ft title , internalname > c:\MeetingSeriesFields.txt

One advantage of powershell that you can also check values of created properties which SPM2010 does not. For example you may wonder how sharepoint keeps EventURL of an Related Event item:
$Site = Get-SPList http://blog.bugrapostaci.com
$web = $site.OpenWeb(“ScrumMeetings”)
$mList = $web.Lists[“Meeting Series”]
$item = $mList.Items[1];
$item[“EventURL”] and press enter
Results is: [URL], [List Title] -> There is a space char after “,” so you should use trim() function when you parsing this data.
https://blog.bugrapostaci.com/lists/TestCalender, Meeting Calendar
After we complete understanding on Meeting Workspace now contine with our project
MeetingRequestWebPart -> Page Load
- protected void Page_Load(object sender, EventArgs e)
- {
- #region GUI operations
- //Some GUI operations
- #endregion
- //This webpart is only usable for Meeting Workspace Sites.
- if (!SPMeeting.IsMeetingWorkspaceWeb(SPContext.Current.Web))
- {
- InformationText.Text = “This webpart is only addable for a Meeting Workspace Web Site”;
- AdminPanel.Visible = false;
- return;
- }
- //Get Current Meeting information
- SPMeeting currentMeeting = SPMeeting.GetMeetingInformation(SPContext.Current.Web);
- MeetingInfo info = MeetingInfo.GetMeetingInfo(currentMeeting);
- //Only the meeting organizer manage meetigs.
- if (!info.OrgnaizerAccount.Equals(SPContext.Current.Web.CurrentUser.LoginName, StringComparison.InvariantCultureIgnoreCase))
- {
- InformationText.Text = “Only Organizer of this meeting \”” + info.OrganizerName + “\” can manage the requests”;
- AdminPanel.Visible = false;
- }
- else
- {
- if (IsAppointmentExists(info.MeetingIdentifier)) //if Meeting request is already sent.
- {
- SavedMeetingInfo = LoadAppointment(info.MeetingIdentifier);
- btnSendMeetingRequest.Visible = false;
- btnReSendMeetingRequest.Visible = true;
- btnCancelMeeting.Visible = true;
- btnRefreshAttendeesStatus.Visible = true;
- if(!_ByPassClearInfo)
- InformationText.Text = “Meeting requests have been send at” + SavedMeetingInfo.RequestSentDate.ToLongDateString() + ” “ + SavedMeetingInfo.RequestSentDate.ToLongTimeString();
- }
- else // if not sent before
- {
- btnSendMeetingRequest.Visible = true;
- btnReSendMeetingRequest.Visible = false;
- btnCancelMeeting.Visible = false;
- btnRefreshAttendeesStatus.Visible = false;
- }
- //assign button events.
- btnSendMeetingRequest.Click += new EventHandler(btnSendMeetingRequest_Click);
- btnReSendMeetingRequest.Click += new EventHandler(btnReSendMeetingRequest_Click);
- btnCancelMeeting.Click += new EventHandler(btnCancelMeeting_Click);
- btnRefreshAttendeesStatus.Click += new EventHandler(btnRefreshAttendeesStatus_Click);
- }
- }
…
In Page Load,
We are doing some gui operations.
Checking webpart added correct web site template , should be a meeting workspace template
Getting Current and latest meeting information
Checking the owner mean organizer beacuse only orginazer manages meetings.
Prepare GUI according to if meeting is already send or not.
Also we set here the SavedMeetinfo property of control via fallowing line
-> SavedMeetingInfo = LoadAppointment(info.MeetingIdentifier);
MeetingInfo LoadAppointment(string identifer) helper function brings us the Saved MeetingInfo in previous state from web.Properies bag.
That information is imported because we are storing Exchange Appointment object’s ID in this object.
MeetingRequestWebPart -> Refresh Attendees Status
- public void RefreshAttendeesStatus()
- {
- if (SavedMeetingInfo == null) return;
- ExchangeServiceConnection conn = new ExchangeServiceConnection(SPContext.Current.Web.CurrentUser);
- SPMeeting currentMeeting = SPMeeting.GetMeetingInformation(SPContext.Current.Web);
- Appointment app = Appointment.Bind(conn.Service, SavedMeetingInfo.AppointmentID);
- Dictionary<string, MeetingResponseType> aStatus = new Dictionary<string, MeetingResponseType>();
- foreach (Attendee att in app.RequiredAttendees)
- {
- if (att.ResponseType != null)
- {
- aStatus.Add(att.Address, (MeetingResponseType)att.ResponseType);
- }
- }
- foreach (Attendee att in app.OptionalAttendees)
- {
- if (att.ResponseType != null)
- {
- aStatus.Add(att.Address, (MeetingResponseType)att.ResponseType);
- }
- }
- RunAsAdmin.Run((site, web) =>
- {
- SPList Attendees = web.Lists[“Attendees”];
- foreach (SPListItem item in Attendees.Items)
- {
- SPUser user = web.EnsureUser(item.Title);
- if (aStatus.ContainsKey(user.Email))
- {
- MeetingResponseType rtype = aStatus[user.Email];
- item[“Response”] = ExchangeHelper.ConvertSPMeetingResponse(rtype);
- item.Update();
- }
- }
- });
- }
In refresh attendees function,
We are getting current Meeting information and already created Appointment object. For updating attendees status a meeting request must already be created.
Collecting all Attedees and thier responses in a dictionary (considering performance )
Updating Attendees status in web.Lists[“Attendees”] list . We are converting Response type beacuse Exchange.MeetingResponseType has 6 option but Response (Choice)
Column in attendees list only 4 option that none,Accepted,Declined,Tentative
MeetingRequestWebPart -> Update Meeting Request
- public void UpdateMeetingRequest()
- {
- if (SavedMeetingInfo == null) return;
- ExchangeServiceConnection conn = new ExchangeServiceConnection(SPContext.Current.Web.CurrentUser);
- SPMeeting currentMeeting = SPMeeting.GetMeetingInformation(SPContext.Current.Web);
- Appointment app = Appointment.Bind(conn.Service, SavedMeetingInfo.AppointmentID);
- MeetingInfo info = MeetingInfo.GetMeetingInfo(currentMeeting);
- ExchangeHelper.UpdateAppointment(app, info);
- //Clear All Attendees
- app.RequiredAttendees.Clear();
- app.OptionalAttendees.Clear();
- //Add Atteendees from Workspace Attendees List.
- AddAttendees(app);
- try
- {
- app.Update(ConflictResolutionMode.AutoResolve);
- info.AppointmentID = SavedMeetingInfo.AppointmentID;
- InfoMessage = “Meeting Request sent successfully”;
- }
- catch (Exception ex)
- {
- ULSLoggingService.LogError(ULSLoggingService.SMR_ERROR, ex.Message + Environment.NewLine + ex.StackTrace);
- InfoMessage = “An Error occured.Please contact your administrator”;
- }
- UpdateAppointment(info);
- }
In UpdateMeetingRequest Function ;
First we checking SavedMeetingInfo object is exists.
Creating an exchange connection.
Getting current meeting.
Appointment app = Appointment.Bind(conn.Service, SavedMeetingInfo.AppointmentID); // with this line we are binding already created Appointment object in Exchange. SavedMeetingInfo object contains AppointmentID which i mentioned above.
We are setting old Appointment object with new values by calling ExchangeHelper.UpdateAppointment(app, info);
(Basically we are doing in ExchangeHelper.UpdateAppointment something like below:
app.Subject = info.Title;
app.Start = info.EventDate;
app.End = info.EndDate;
app.Location = info.Location;
…. return app; )
Clearing All Attendeess
Add all attendees again
Update Appointment object that will resend all meeting request again via app.Update() command.
Set AppointmentID to new MeetingInfo class instance.
Update new MeetingInfo class via overriding old MeetingInfoClass (SavedMeetingInfo)
MeetingRequestWebPart -> Cancel Meeting Request
- public void CancelMeetingRequest()
- {
- if (SavedMeetingInfo == null) return;
- ExchangeServiceConnection conn = new ExchangeServiceConnection(SPContext.Current.Web.CurrentUser);
- SPMeeting currentMeeting = SPMeeting.GetMeetingInformation(SPContext.Current.Web);
- try
- {
- //Get existed appointment.
- Appointment app = Appointment.Bind(conn.Service, SavedMeetingInfo.AppointmentID);
- app.CancelMeeting();
- ClearAppointment(SavedMeetingInfo);
- InfoMessage = “Meeting has been canceled successfully.”;
- }
- catch (Exception ex)
- {
- ULSLoggingService.LogError(ULSLoggingService.SMR_ERROR, ex.Message + Environment.NewLine + ex.StackTrace);
- InfoMessage = “An error occured.Please contact your administrator”;
- }
- }
In CancelMeetingRequest function:
Like before we are checking SavedMeetInfo is exists , creating an exchange connection object and getting currentmeeting object.
Appointment app = Appointment.Bind(conn.Service, SavedMeetingInfo.AppointmentID); // with this line we are binding already created Appointment object in Exchange.
And Canceling Meeting via app.CancelMeeting() function.
Clearing previously saved MeetingInfo instance from web.properties.
PS: There is a trick when you try removing a property correctly from SPWeb object .Check the fallowing link:
https://blog.bugrapostaci.com/2012/02/17/clearing-or-removing-a-keyvalue-from-spweb-properties-tipstricks/
Next Article: Part 3 Deployment.