Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Microsoft Graph API Error – At least one recipient is not valid., A message can't be sent because it contains no recipients

I am using microsoft Graph API to send email. I have set up my application in Entra.
I am first saving a draft using API – https://graph.microsoft.com/v1.0/me/messages

Which gave me response –

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('02720573-7ab2-4d63-b61b-97da9c881a5c')/messages/$entity",
"@odata.etag": "W/\"CQAAABYAAAAtK9qWA0ShRKzuJQcuV7P9AAAEfmZ6\"",
"id": "AAMkADg1ZmUzYWU2LWNmNTEtNDNkYS1iMTMxLTE2ZWE3NThjOTJlNQBGAAAAAABc1YMkdg4qT74XBMUltssfBwAtK9qWA0ShRKzuJQcuV7P9AAAAAAEPAAAtK9qWA0ShRKzuJQcuV7P9AAAEglX3AAA=",
"createdDateTime": "2024-02-09T09:52:12Z",
"lastModifiedDateTime": "2024-02-09T09:52:12Z",
"changeKey": "CQAAABYAAAAtK9qWA0ShRKzuJQcuV7P9AAAEfmZ6",
"categories": [],
"receivedDateTime": "2024-02-09T09:52:12Z",
"sentDateTime": "2024-02-09T09:52:12Z",
"hasAttachments": false,
"internetMessageId": "<DS0PR19MB7345B954A5D38B99DA52E775A24B2@DS0PR19MB7345.namprd19.prod.outlook.com>",
"subject": "5Feb",
"bodyPreview": "5Feb",
"importance": "normal",
"parentFolderId": "AQMkADg1ZmUzYWU2LWNmNTEtNDNkYS1iMTMxLTE2ZWE3NThjOTJlNQAuAAADXNWDJHYOKk__FwTFJbbLHwEALSvalgNEoUSs7iUHLlez-QAAAgEPAAAA",
"conversationId": "AAQkADg1ZmUzYWU2LWNmNTEtNDNkYS1iMTMxLTE2ZWE3NThjOTJlNQAQAAeqIgr5i85AkWtRk-vVNEI=",
"conversationIndex": "AQHaWz2nB6oiCvmLzkCRa1GT+9U0Qg==",
"isDeliveryReceiptRequested": false,
"isReadReceiptRequested": false,
"isRead": true,
"isDraft": true,
"webLink": "https://outlook.office365.com/owa/?ItemID=AAMkADg1ZmUzYWU2LWNmNTEtNDNkYS1iMTMxLTE2ZWE3NThjOTJlNQBGAAAAAABc1YMkdg4qT74XBMUltssfBwAtK9qWA0ShRKzuJQcuV7P9AAAAAAEPAAAtK9qWA0ShRKzuJQcuV7P9AAAEglX3AAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification": "focused",
"body": {
    "contentType": "text",
    "content": "5Feb"
},
"toRecipients": [
    {
        "emailAddress": {
            "name": "nileshkemse7@gmail.com",
            "address": "nileshkemse7@gmail.com"
        }
    }
],
"ccRecipients": [],
"bccRecipients": [],
"replyTo": [],
"flag": {
    "flagStatus": "notFlagged"
}

}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Now when I try to send this draft mail using – https://graph.microsoft.com/v1.0/users/02720573-7ab2-4d63-b61b-97da9c881a5c/sendMail

It gives me following error

{
"error": {
    "code": "ErrorInvalidRecipients",
    "message": "At least one recipient is not valid., A message can't be sent because it contains no recipients."
}

}

I am trying this from postman. Same was working fine two days before. Can there be any permission issue which admin might have removed? But I am calling this API through delegated access and access token has scopes – IMAP.AccessAsUser.All Mail.Read Mail.Read.Shared Mail.ReadBasic Mail.ReadBasic.Shared Mail.ReadWrite.Shared Mail.Send.Shared profile User.Read openid email

Can someone help what could be the issue?

>Solution :

You are using wrong endpoint for sending a draft. Use the id from the previous response in the following request

POST https://graph.microsoft.com/v1.0/users/{user_id}/messages/{message_id}/send
POST https://graph.microsoft.com/v1.0/me/messages/{message_id}/send

The endpoint you were using

POST https://graph.microsoft.com/v1.0/users/{user_id}/sendMail

sends a message specified in the body and it can be used for sending a draft.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading