'Outlook add-in sync events

Developing an outlook add-in you can add buttons which for example allow you to add additional meta information to a meeting event. Assume you have an add-in that links events with an external system when user presses a button.

Now that is all fine but now the user can also delete the event and in this case you also want to delete it on your external system. Now there are no easy events you can just register to.

You seem to have the option to subscribe for event web-hooks on the graph api on the behalf of the user. However such a subscription has the maximum lifetime of 3 days. Alternatively you could also use the deltaAPI to detect potential deletion of calendar events.

But your add-in does only run when the user clicks a button and only then you could renew an event subscription or execute a delta query. But then you see that there exists also event based activation possibilities that you could consider. You could use it to renew web-hook event subscriptions if needed or execute delta-queries directly to detect changes. Now it seems event-based add-in is a special kind of add-in you cannot easily distributed as the docs state:

Important

Event-based add-ins are restricted to admin-managed deployments only. For now, users can't get event-based add-ins from AppSource or in-app Office Store. To learn more, refer to AppSource listing options for your event-based Outlook add-in.

And even it does not pair easily with SSO which obviously you need because you need access-tokens to subscribe for web-hooks or execute delta queries.

So in this Microsoft office add-in world: What is the idea to react on deleted events? How is this possible in a feasible way? Right now it feels like fighting a crazy three feeted drunk dragon rolling in circles around a green stone (or imagine something else that does not make sense) with nothing more than a bendable pencil made of plastic.



Solution 1:[1]

Does your app need to be an addin? You can create a standalone app that uses Graph. Or you can create a COM (VSTO) addin (Windows only) - it will run every time Outlook is running and use events in the Outlook Object Model.

Solution 2:[2]

You are absolutely right - web add-ins are limited in their functionality. All that you could do is to use Graph API. Outlook web add-ins are designed for running under the context of currently selected item only. As soon as the add-in is activated for the item you can run the code to make Graph API calls.

Unlike web add-ins, VSTO provides a rich set of API that doesn't require making Graph API calls. But in that case there is a big limitation for using such add-ins - Outlook desktop on Windows only.

Be aware, that Graph API can be called from any application, not only from web add-ins. So, may be you will think about a possible implementation without add-ins involved. Or your web add-in may call an external web service (yours) where it could make the required Graph API calls. Read more about that in the Scenario: Implement single sign-on to your service in an Outlook add-in article.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitry Streblechenko
Solution 2 Eugene Astafiev