Share via

Getting 401 error while using graph api to send email /me/sendMail

Ibrahim Mufti 0 Reputation points
2025-09-02T09:44:07.4166667+00:00

Hello im creating a project that sends email on behalf of the user the issue is my Authentication, Authorization, Refreshing of token is working correctly the issue is with the
api https://graph.microsoft.com/v1.0/me/sendMail

the request is being send in this manner where we add headers => Authorization: Bearer acccessToken

i dont know what the issue is but im getting 401 error event checked the token validation and the token was not yet expired and contains the scope these scopes
Mail.ReadWrite Mail.Send User.Read profile openid email !!!
and the token claims have these scopes as these

"scp": "Mail.ReadWrite Mail.Send User.Read profile openid email"

PS: i dont have microsoft 365 license neither i have signed for developer program as it is not qualifying me for the program

Best regards
Muhammad Ibrahim Mufti

Microsoft Security | Microsoft Entra | Microsoft Entra ID

1 answer

Sort by: Most helpful
  1. Anonymous
    2025-09-04T21:02:18.6966667+00:00

    @Ibrahim Mufti
    The most likely cause of the 401 Unauthorized error, even with the correct scopes, is that the user account you are authenticating with does not have an active Microsoft 365 license with an Exchange Online mailbox.

    The /me/sendMail API endpoint requires a user to have a functioning mailbox to send emails. An Exchange Online mailbox is only created when a user has a license that includes this service. The scopes (Mail.Send, Mail.ReadWrite, etc.) grant your application the permission to act on the user's behalf, but the user themselves must have the underlying capability to send mail.

    This is a common point of confusion. While your authentication and token are correct, and the token contains all the necessary permissions, the 401 error is not about your application's permissions; it's about the user's lack of a licensed mailbox.

    Since you mentioned you don't have a Microsoft 365 license and don't qualify for the developer program, the account you're using for testing likely doesn't have an associated mailbox, which is a hard requirement for the sendMail functionality.

    I hope this helps in resolving the issue, do let me know if you have any further questions on this

    Was this answer helpful?


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.