none
Using EWS to cancel a meeting in a room mailbox. RRS feed

  • Question

  • This seems like a common occurrence 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 (i.e. the organizer no longer exists).  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 Exchange 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).  It's not full code, just a proof of concept to get the cancellation working (the first item found is a meeting I want to cancel).  

    The goal is to have something that'll go through my room mailboxes looking for appointments where the organizer doesn't map to an existing object (it'll show up as an X500 address) and if found cancel the meeting (and inform all known attendees).  The idea being that since the person is gone the slot in the room should be freed up.

    Any thoughts or input that could be helpful would be much appreciated.  As things are now I'm considering deleting the meeting and then just sending an email via SMTP to the attendees to ask them to remove it from their calendars, but that's less than idea.

    #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)
    	
    #Send the cancellation
    $frCalendarResult.Items[0].CancelMeeting("This meeting has been canceled.")

    Thursday, May 30, 2013 6:30 PM

Answers

  • The Business logic in OWA,Outlook and EWS will stop anybody other then the Organizer of an appointment from Canceling it so none of the standard API methods will work.

    One workaround that may work is manually creating the Ipm.Schedule.Meeting.Canceled Message and setting all the correct extended properties, but I've never seen anybody try this so its something you'll need to research and probably reverse engineer and test.

    Cheers
    Glen

    Friday, May 31, 2013 10:10 AM

All replies

  • The Business logic in OWA,Outlook and EWS will stop anybody other then the Organizer of an appointment from Canceling it so none of the standard API methods will work.

    One workaround that may work is manually creating the Ipm.Schedule.Meeting.Canceled Message and setting all the correct extended properties, but I've never seen anybody try this so its something you'll need to research and probably reverse engineer and test.

    Cheers
    Glen

    Friday, May 31, 2013 10:10 AM
  • Thanks Glen.  What I'm considering doing since the original organizer isn't around anymore is using EWS to actually go into each attendees mailbox and removing the meeting if found and then emailing the attendee to let them know what was done.  The 'clean' way to do it would be what you're suggesting...if it's possible and it works.  I'll give that a whirl first and if that doesn't do it I'll go to plan B.

    I'm kind of surprised this doesn't come up more often.  Where I work we have ~3000 conference rooms and just in the month of June there are 600 meetings where the organizer no longer exists (so the room looks booked to other people).  Finding an open conference room has become something of a chore for the entire company and I'm hoping to clean it up a bit...maybe cancel meetings as people are terminated too.

    Friday, May 31, 2013 6:09 PM
  • Hi Steve,

    I am in a similar situation. Did you ever find a solution ?

    Thursday, October 17, 2013 5:40 PM