Share via

How to avoid Microsoft change notifications when an email is deleted or moved to another folder?

Umair Ahmed 56 Reputation points
2021-11-18T06:50:02.08+00:00

We're using Microsoft change notifications to listen to new emails in a user's overall mailbox. The notifications are subscribed as follows:

{
  "changeType": "created",
  "notificationUrl": "{our-internal-api-endpoint}",
  "resource": "/me/messages",
  "expirationDateTime": "{expiry-time}",
  "clientState": "SecretClientState"
}

The subscriptions work as intended: When a new email arrives in the mailbox, a notification is sent to our API endpoint. The problem is that when we deleted an email (which is basically moving it to Deleted Items folder) or move an existing email from one folder to another folder, a notification is triggered again.

We get that moving an email to another folder basically creates a new email in that folder and for that reason, Microsoft sends a new notification but, we don't want to receive notifications for emails moved to a folder but only for new emails that arrive in the mailbox. Is there any way to avoid these notifications?

Any help shall be appreciated greatly.

Microsoft Security | Microsoft Graph

1 answer

Sort by: Most helpful
  1. Sheena-MSFT 1,736 Reputation points
    2022-01-26T14:44:14.887+00:00

    Hi @Umair Ahmed ,

    we can subscribe to me/mailFolder/{id}/messages to get change notifications when a message is created in a particular mail folder.

    for example if you want to get notified when a new mail arrived in inbox use the following

       {  
              "changeType": "created",  
                "notificationUrl": "{xxxxx}",  
               "resource": "/me/mailFolder/('Inbox')/messages",  
                "expirationDateTime": "{expiry-time}",  
               "clientState": "SecretClientState"  
            }  
    

    Hope this helps.

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

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

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.