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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,861 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,590 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 37,871 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.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful