EWS managed API: update method for an appointment creates an error message RRS feed

  • Question

  • I have created a powershell script using EWS managed API to update some appointments in my Calender. When I run the sript under my account the script is working properly. But when I run it under another account which is having full maibox access and send as permission the script fails.

    When callin the update() method for an appointment the following message comes up:

    Exception calling "Update" with "2" argument(s): "When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address f
    or any distinguished folder Ids."
    At C:\Documents and Settings\adm.kraehfri\My Documents\Scripts\Sync-Calendar.ps1:61 char:32
    +             $appointment.update <<<< ([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AlwaysOverwrite,
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    Can anybody tell me what I am doing wrong?

    Here is the code I am using (removed some statemants which are not relevant for the problem):

    [system.reflection.assembly]::loadfile("C:\WINDOWS\system32\Microsoft.Exchange.WebServices.dll") | out-null
    $MBXName = "<my mailbox address>"
    # connect to Exchange 2007 SP1                                                                                        !
    $exVersion = New-Object Microsoft.Exchange.WebServices.Data.exchangeversion
    $ews = New-Object Microsoft.Exchange.WebServices.Data.exchangeservice($exversion)

    $ews.UseDefaultCredentials = $true
    $Mailbox = new-object Microsoft.Exchange.WebServices.Data.mailbox($MBXName)
    $CalendarId = new-object[]::Calendar,$Mailbox)
    $Calendar = []::bind($ews,$CalendarId)
    $StartDate = [system.datetime]"09.1.2012"
    $EndDate = $Startdate.Addmonths(1)
    $CalendarView = New-Object$Startdate,$EndDate)
    $Propset = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)

    $AppointmentsFound = $ews.FindAppointments($Calendar.Id, $Calendarview)
    if ($AppointmentsFound.items.count -gt 0) {

    foreach ($appointment in $AppointmentsFound) {
        if ($appointment.isrecurring) {
             do something with recurring meeting    }
        else {
            "$($appointment.start) - $($appointment.end), Category: $($appointment.categories)"
            if ($appointment.organizer.address -eq $MBXName -and !$appointment.MeetingRequestWasSent `
                -and !($appointment.categories -contains "Feiertag" -or $appointment.categories -contains "Holiday")) {
                $appointment.RequiredAttendees.add("<another mailbox address>")

    ([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AlwaysOverwrite,                                [Microsoft.Exchange.WebServices.Data.SendInvitationsOrCancellationsMode]::SendOnlyToAll)

    • Edited by Kilitop Thursday, September 6, 2012 1:51 PM
    Wednesday, September 5, 2012 9:17 AM