none
Exchange web services - Add Calendar event direct to Shared Mailbox RRS feed

  • Question

  • Hi,

    [EWS, Powershell, Shared Mailboxes on Exchange 2010 SP1]

    I would like to add an Appointment to a Shared Mailbox Calendar that I have Full Access to.  (Microsoft.Exchange.WebServices.Data.Appointment) I do not use Impersonation just GetCurrent() Windows.Identity (already allows me access to Shared Mailbox Inboxs, Sent Items etc).  Every time I use the (snippet) code below, the corresponding $appointment gets created in my own Calendar and not the Calendar of the Shared Mailbox.  Even so I can still see a summary of items in the Shared Mbx Calendar etc.

    $folderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$mailbox)
    $CalendarItem = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($service,$folderID)
    $appointment = New-Object Microsoft.Exchange.WebServices.Data.Appointment -ArgumentList $service

    The Binding of $Service and $FolderID doesnt return an error yet I cannot figure out where there error is. 

    Is it even possible to directly create an appointment in another calendar using EWS / Powershell?

    Help appreciated.

    Thanks,


    Monday, March 11, 2013 9:43 PM

Answers

  • When you save the appointment do to specify the FolderId ? eg

    $appointment.save($CalendarItem.Id)

    You need to list all your code

    Cheers
    Glen

    • Marked as answer by eirelive Tuesday, March 12, 2013 8:06 AM
    Tuesday, March 12, 2013 6:31 AM

All replies

  • When you save the appointment do to specify the FolderId ? eg

    $appointment.save($CalendarItem.Id)

    You need to list all your code

    Cheers
    Glen

    • Marked as answer by eirelive Tuesday, March 12, 2013 8:06 AM
    Tuesday, March 12, 2013 6:31 AM
  • Excellent Glen, that has worked perfectly.

    ## including working code that enables a user with Full Control over a Shared Mailbox to enter a Calendar Item into Calendar of Shared Mailbox.

    $mailbox = "sharedmailbox@yourdomain.com"
    $casservername = "caa.yourdomain.com"
    $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll"
    [void][Reflection.Assembly]::LoadFile($dllpath)
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010)
    $uri=[system.URI] ("https://" + $casserverName + "/ews/exchange.asmx")
    $service.Url = $uri
    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
    $aceuser = [ADSI]$sidbind

    $folderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$mailbox)

    $CalendarItem = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($service,$folderID)

    $appointment = New-Object Microsoft.Exchange.WebServices.Data.Appointment -ArgumentList $service
    $appointment.Subject = "Dept. Users Holiday"
    $appointment.Body = "This person is on leave"
    $appointment.Start = "03/17/2013"
    $appointment.end = "03/18/2013"
    $appointment.IsAllDayEvent = $true
    $appointment.LegacyFreeBusyStatus = "OOF"
    $appointment.Save($calendaritem.ID)

    # within 30 seconds the event will appear in the Shared Mailbox calendar (in Outlook). Last Modified listed is Displayname of SMbx.

    Something I need to work on is that on opening the appointment is that it shows the appointment as invitation with To.. field as empty. foreach loop needed to add multiple items from CSV.

    thanks,

    Tuesday, March 12, 2013 8:23 AM