I want to send an email from a seperate user, but I keep getting error

Banter Software 1 Reputation point
2021-10-16T22:18:10.897+00:00

I am using the graph API https://graph.microsoft.com/v1.0/users/{userId}/sendMail.

I keep getting the error of "The specified folder could not be found in the store"

I just need to be able to send emails using the API from different aliases. Can someone help?

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sheena-MSFT 1,736 Reputation points
    2021-12-30T18:36:18.23+00:00

    Hi @Banter Software ,

    To achieve your requirement you can use below two approaches.

    Approach 1:
    To send messages from another user using Graph API, configure application token with mail.send permission and needs to be consented by an administrator as mentioned here https://learn.microsoft.com/en-us/graph/outlook-send-mail-from-other-user

    We will be able to send email as any other user in the organization by sending the mail normally through the user's mailbox with application permission using the below endpoint

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

    Approach 2:

    In order to send messages from another user using Graph Explorer(delegated permission), two type of permissions are required such as Microsoft graph permissions and mailbox permissions.
    Use Mail.send.Shared graph permission as delegated.
    We have two types of mailbox permissions, send on Behalf and Send As and we can configure these permissions as mentioned here https://learn.microsoft.com/en-us/microsoft-365/admin/add-users/give-mailbox-permissions-to-another-user?view=o365-worldwide.
    161440-mailboxperm.png
    The user who logged in to your application with the Mail.Send.Shared permission MUST have at least one of these permissions

    • Send on Behalf
    • Send As granted to the mailbox, group, or distribution list that the mail is from. Also need to set from address to the mailbox address in which the permissions are granted.
      Reference example below: POST https://graph.microsoft.com/v1.0/me/sendMail.
      {
      "message": {
      "subject": "Meet for lunch?",
      "body": {
      "contentType": "Text",
      "content": "The new cafeteria is open."
      },
      "toRecipients": [
      {
      "emailAddress": {
      "address": "xxxxxx.onmicrosoft.com"
      }
      }
      ],
      "from": {
      "emailAddress": {
      "address": "xxxxxx.onmicrosoft.com"
      }
      }
      }
      }

    161484-mailboxperm1.png

    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".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.