Not able to send mail.

Devin Goodson 40 Reputation points
2025-04-21T18:21:40.4866667+00:00

Not able to send mail. I have register app on azure. I also give all permissions including mail.send & also granted admin consent. But still giving unauthorized error while sending mail..

Kindly refer screenshot attached...to check which url I used.

Note: i. I have successfully generated access token & using it I tried to send mail.
ii. But we are able to send mail using Microsoft Graph Explorer. But when we tried same using postman, it fails.image

Microsoft Security | Microsoft Entra | Microsoft Entra ID

Answer accepted by question author
Anonymous
2025-04-23T10:53:54.4866667+00:00

Hello @Devin Goodson,

I understand that you want to send mail using Microsoft Entra ID application. And I observe that you have assigned Mail.Send application type API permission.

enter image description here

Note: If you want to make use of Application type API permission to send mail, then you need to make use of Client Credential Flow to generate access token.

If you grant application type API permission and make use of use any user interactive flow to generate access token, then you will get 401 Unauthorized error.

To send mail using application type API permission, generate access token using Client Credential Flow:


GET https://login.microsoftonline.com/TenantID/oauth2/v2.0/token

client_id: ClientID

client_secret: Secret

scope: https://graph.microsoft.com/.default

grant_type: client_credentials

enter image description here

Make sure to decode the token and check if roles claim contains Mail.Send role:

enter image description here

Now use the below query to send mail:


POST https://graph.microsoft.com/v1.0/users/******@domain.onmicrosoft.com/sendMail

Content-type: application/json

{

  "message": {

    "subject": "Meet for lunch?",

    "body": {

      "contentType": "Text",

      "content": "The new cafeteria is open."

    },

    "toRecipients": [

      {

        "emailAddress": {

          "address": "******@contoso.com"

        }

      }

    ],

    "ccRecipients": [

      {

        "emailAddress": {

          "address": "******@contoso.com"

        }

      }

    ]

  },

  "saveToSentItems": "false"

}

Mail sent successfully:

enter image description here

Also make sure that the user has Microsoft 365 or Office 365 license assigned:

User's image

Reference:

user: sendMail - Microsoft Graph v1.0 | Microsoft Learn


If this answer was helpful, please click "Accept the answer" and mark Yes, as this can help other community members.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Oldest

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.