Garethp / php-ews

PHP Exchange Web Services
BSD 3-Clause "New" or "Revised" License
112 stars 45 forks source link

Set a calendar event with custom identifier, so that I can (later on) GET an event by the same identifier #256

Open Lxxrxns opened 8 months ago

Lxxrxns commented 8 months ago

Hey there!

Thank you for this excellent PHP library!

I am trying to make a script that synchronizes a schedule I have in my MySQL database to an EWS. To do this, I was hoping to set a unique field in the EWS event data that I can later select, i.e. a unique number that I can search for to then get the $itemId to update or delete the event later if necessary.

In the examples, I was only able to find code that selects the FIRST event ( $item = $calendar->getCalendarItems()[0] ) (or any other event if the position in the array is known), but my question is:

Is it possible to do something like:

$calendar->createCalendarItems(array(
    'uniqueIdentifier' => 'abc123',
    'Subject' => 'Test',
    'Start' => $start->format('c'),
    'End' => $end->format('c')
));

And then later on do something like:

getCalendarItems( WHERE uniqueIdentifier = "abc123" )

I could then get the $itemId (the EWS id of the event) and perform other actions such as updateCalendarItem() on that $itemId.

Ideally, the uniqueIdentifier is not visible (or at least not easily EDITABLE) in Outlook for the end user, because that would break the link between my database and the EWS. For example, using a unique code in the event subject is not an option, because this will (a) be very ugly in the user's Outlook and (b) be editable, which would make the EWS event unfindable later on.

Any help would be greatly appreciated.

Laurens

Lxxrxns commented 8 months ago

Update: so I read on StackOverflow that every event in EWS also has a "icalUId" (in the Graph API version), and I'm thinking the "old" EWS also has something similar called "uID".

Is there a way get the $itemId from an event by searching for its uID?

I found this: https://github.com/jamesiarmes/php-ews/issues/508 but that is for jamesiarmes' version... Would that also work here?

Lxxrxns commented 8 months ago

Basically, what I'm trying to do is this:

https://social.msdn.microsoft.com/Forums/exchange/en-US/1f623537-03ce-486e-8e33-4df38b513017/find-an-event-with-a-specific-uid-using-exchange-web-services-2010

Is there a class in php-ews that would work like this? Or is it possible to add one?

Lxxrxns commented 8 months ago

More information:

http://www.infinitec.de/post/2009/04/13/Searching-a-meeting-with-a-specific-UID-using-Exchange-Web-Services-2007.aspx