Hi Osema MEKELLECHE,
Thanks for reaching out to Microsoft!
401 error indicates that the access token is either missing, invalid, or expired.
As mentioned in the document, make sure that your application is presenting a valid access token to Microsoft Graph as part of the request. We strongly recommend that you use the Microsoft Authentication Library (MSAL) for access token acquisition.
Decode token, scp (scope) or roles: Should include the permissions your app needs, like "Mail.Send".
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.