Share via

Graph API Outlook Webhooks

Kyle Webster 20 Reputation points
2023-12-05T18:01:28.3+00:00

I am trying to build a security system to monitor user's incoming emails and determine if the contents contain anything malicious. Initially, I want to use an outlook add-in, but there does not seem to be a way to automatically run the add-in automatically. Is there a way to make this work?

Alternately, is this possible with Graph API's webhooks? If so, what would be the delays be with when the user receives the email and when the script would be activated?

Microsoft 365 and Office | Development | Other
Microsoft Security | Microsoft Graph
0 comments No comments

Answer accepted by question author

CarlZhao-MSFT 46,456 Reputation points
2023-12-08T07:33:33.8133333+00:00

Hi @Kyle Webster

You can receive notifications of changes by creating an email subscription.

POST https://graph.microsoft.com/v1.0/subscriptions
Content-type: application/json

{
   "changeType": "created,updated",
   "notificationUrl": "https://webhook.azurewebsites.net/api/send/myNotifyClient",
   "resource": "users/{id}/mailFolders('Inbox')/messages",
   "expirationDateTime":"2023-12-20T18:23:45.9356913Z",
   "clientState": "secretClientValue",
   "latestSupportedTlsVersion": "v1_2"
}

The delay between when the user receives the email and when the script would be activated depends on several factors, such as the network latency, the load on the Microsoft Graph service, and the response time of your webhook endpoint. As far as I know, the Microsoft Graph change notifications service tries to deliver the notification within 30 seconds of the change. However, this is not a guarantee and the actual delivery time may vary.

Hope this helps.

If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

Was this answer helpful?

2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.