Hello Norris Mwiinga,
Thanks for reaching out!
The mentioned error message code tells that the user is invalid or doesn't exist.
- Make sure the user exists in portal.office.com. I'm able to replicate the error message when I'm passing wrong UPN (non-existing user UPN).
- If the user exists, using this endpoint
GET https://graph.microsoft.com/v1.0/users
, you can query all the users in your tenant. In the response, the response containsid
anduserPrincipalName
that can be used to request the/messages
endpoint. - Make sure the token has right permissions/scopes to access the user's mailbox.
- Split the application calls into smaller modules and check where it's breaking.
You can refer to this documentation to get a token.
Hope this helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".