Using EWS to cancel a meeting in a room mailbox.

This seems like a common occurance at any company but there really doesn't seem to be a solution for it.  In Exchange people can reserve a conference room by inviting it to a meeting and with the proper setup the room mailbox will accept the meeting if the time slot is free.  The problem comes in when the organizer of the meeting leaves the company.  I'm working on a project using Exchange Web Services to clean out our room mailboxes of meetings which were scheduled by people who are no longer at the company.  The only way I know how is through web services and through an account that has been given the impersonation right (which I am using).

The problem I'm having is that through web services there is a method on an appointment item called CancelMeeting which would do just this except I'm getting the below error:

Exception calling "CancelMeeting" with "0" argument(s): "User must be an organizer for CancelCalendarItem action."

I'm looking for any suggestions as I've been looking out over the Internet for quite a bit now and not really coming up with anything of use.  Below is the code I'm using (cleaned up to remove company information).  Any thoughts or input that could be helpful would be much appreciated.

#Address of object to connect to
$roomAddress = 'room@contoso.com'

#Path to the EWS DLL
$dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll"

#Load the EWS DLL
[void][Reflection.Assembly]::LoadFile($dllpath)
	
#Create a service object that supports Exchange 2010 SP1
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP1)
	
#Store the passed in credential
#$service.Credentials = $credential

#Web services url
$uri=[system.URI] "https://ExhcangeServer.Contoso.com/EWS/Exchange.asmx"
$service.Url = $uri
	
#The impersonation details.
$ImpersonatedUserId = New-Object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId
$ImpersonatedUserId.IdType = 'smtpaddress'
$ImpersonatedUserId.Id = $roomAddress
$service.ImpersonatedUserId = $ImpersonatedUserId
#Build a folder ID object
$folderid = new-object  Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$roomAddress)
	
#Bind to the mailbox and folder.
$CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($service,$folderid)
	        
#Get up to 2000 entries from the folder and find any that are appointments from today and the next 5 days.
$startDAte = get-date
$endDate = (get-date).AddDays(+5)
$cvCalendarview = new-object Microsoft.Exchange.WebServices.Data.CalendarView($StartDate,$EndDate,2000)
$frCalendarResult = $CalendarFolder.FindAppointments($cvCalendarview)
	
#Build a view
$psPropset = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$psPropset.RequestedBodyType = [Microsoft.Exchange.WebServices.Data.BodyType]::Text

#Cancel the first meeting found (there is one here)
$frCalendarResult.Items[0].CancelMeeting()


May 30th, 2013 7:21pm

Hi,

I would tackle this in a slightly different way. What I've done in the past is to give myself Editor rights to the Room Mailbox's calendar. That way I can just add the calendar and delete the meetings. If this sounds like something you'd like to try, run this command:

Set-MailboxFolderPermission -Identity RoomMailboxAccount:\Calendar -User userName -AccessRights Editor



Replace RoomMailboxAccount with the username of the room mailbox account and userName with your username.


Free Windows Admin Tool Kit Click here and download it now
May 30th, 2013 9:05pm

If it was one or two mailboxes that'd be ok, but we have over 3,000 :) and this needs to be a regular thing (to keep rooms free of meetings submitted by terminated people).  I need a programmatic way of doing it and my goal is to have it actually send out a cancellation.
May 30th, 2013 9:14pm

Oh, ouch. In that case, I might also try asking in the Exchange development forum. They're a bit more versed in EWS than I am.

http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopmentlegacy/threads

I do have a script that uses EWS to set a delegate on a specific calendar (it was written for standard users, not sure how it'll handle room mailboxes. Perhaps delegate rights will be enough to send out cancellation notices. I can clean it up and post it (after I get out of this afternoon meeting) if you think it might help.

Free Windows Admin Tool Kit Click here and download it now
May 30th, 2013 9:21pm

Thanks Mike I wasn't aware of that forum.  I'll post over there.  Thanks!  I'm considering just deleting the meeting and emailing the attendees, but that's not as 'nice' as an actual cancellation.
May 30th, 2013 9:24pm

Were you able to get this working?
Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2014 5:13pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics