Search code examples
pythonmicrosoft-graph-api

How to update read status of an email using MS Graph Api


I am trying to use python and MS Graph Api to read emails from outlook. My intention is to create ticket object in our CRM application whenever any email comes. So, my application is to monitor the mailbox to see if any mails are staying unread. I am able to successfully login and read all unseen email from outlook. But emails are not getting marked as "read" email even though read by my program. it is shown as unread and that causes to create duplicate tickets in my application. is there any way to mark as read once we read by API call? Please see the python code I am using

read_url = 'https://graph.microsoft.com/v1.0/users/{}/messages'.format(
            self.userId)
#user id will be given 

response = requests.get(read_url,
     
                                headers={ 

 'Authorization': 'Bearer ' + self.result['access_token']})

#token will be generated


Solution

  • there is a property isRead on each email. This means You have to update each email Your app process with PATCH request and isRead set to true.

    You can find more info in official docs