jamesiarmes / php-ews

PHP Exchange Web Services
http://jamesarmes.com/php-ews/
MIT License
567 stars 302 forks source link

Delete a calendar event and move it to trash folder #534

Closed jkellermin closed 5 years ago

jkellermin commented 5 years ago

Version (e.g. 1.0, dev-master): 1.0 PHP version: 7.1 Microsoft Exchange version: 2016 Description of problem: I've searched in examples provided but did not find how to delete an item in calendar. The script below work but cancel the event, and save an item in the draft folder. I would like to delete the appointment and move it to the trash folder. Thanks for your help !

Example request:

$request = new CreateItemType();
$request->MessageDisposition = MessageDispositionType::SAVE_ONLY;
$request->SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType::SEND_TO_NONE;
$request->Items = new NonEmptyArrayOfAllItemsType();
$cancellation = new CancelCalendarItemType();
$cancellation->ReferenceItemId = new ItemIdType();
$cancellation->ReferenceItemId->Id = $exchange_id;
$cancellation->ReferenceItemId->ChangeKey = $changekey;
$request->Items->CancelCalendarItem[] = $cancellation;
$response = $client->CreateItem($request);

Example response:

Additional details: