1

I am having problems setting the IsRead property when reading email, and after lots of Googling the following appears to be the code required.

await Client.Me.Messages[m.Id].Request().Select("IsRead").UpdateAsync(new Message() { IsRead = true });
                           

The problem is this is returning:

Mail Exception: Code: ErrorAccessDenied

Message: Access is denied. Check credentials and try again

ClientRequestId: (the id here)

The Microsoft Graph Docs says the permissions required are Mail.ReadWrite. I have confirmed we have that.

Other problems on Stackoverflow include Fails to mark as read, but my problem is one of access denied, rather than trying to set read-only properties.

I've also tried the code from here: Github Graph Issue but again, I'm getting Access Denied.

The app has the following permissions: Mail.Read

Mail.ReadBasic

Mail.ReadBasicAll

Mail.ReadWrite

Mail.Send

MailboxSettings.Read

MailboxSetings.ReadWrite

User.Read

User.ReadAll

Is there anything else required?

DaveEP
  • 1,426
  • 4
  • 13
  • 27
  • (1) Do you see the above issue with only a selected messages or with all the messages? (2) Can you repro the issue with Microsoft Graph explorer against the same message as well? – Dev Jan 07 '21 at 12:08
  • It's happening on all messages. Not sure how to test this with Graph Explorer, I'll look in to that as well. – DaveEP Jan 07 '21 at 12:36
  • oh, but its strange. Which AAD flow that you implemented? I see that you're calling me endpoint, so i suspect it would be delegated permissions. – Dev Jan 07 '21 at 12:40
  • Try the following steps: (1) Open https://developer.microsoft.com/en-us/graph/graph-explorer (2) login the same mailbox that you're trying above (3) Get the id of the message that you're trying (4) Make the API call for the given message using its id (5) Observe the result. – Dev Jan 07 '21 at 12:41
  • Bingo! The endpoint was the problem. Thanks for your very fast response on this, it's now working :) – DaveEP Jan 07 '21 at 12:53
  • oh wow!! Glad to hear that its working :) – Dev Jan 07 '21 at 13:08
  • Let me move this to answer. Consider accept it as answer and upvote it. So it can be useful to the others in the community as well. – Dev Jan 07 '21 at 13:08

1 Answers1

1
  • As you can repro the issue with all the messages, i suggested to try the same with Microsoft Graph explorer outside of the code.
  • Based on your check, you found that the endpoint was the problem. By providing the right endpoint, it worked.
Dev
  • 2,428
  • 2
  • 14
  • 15