title: Outlook REST API - Send As
body: <p>I am currently using the Outlook REST API to send email. This is working fine when sending from a user mailbox such as:</p>
  
  <p><a href="https://outlook.office.com/api/v2.0/users/user@domain.com/sendMail" rel="nofollow noreferrer">https://outlook.office.com/api/v2.0/users/user@domain.com/sendMail</a></p>
  
  <p>'user@domain.com' is the UPN of a valid user account in Azure AD.</p>
  
  <p>What I need to do is 'send as' a shared mailbox. According to the documentation this can be achieved by changing the 'From' property in the JSON request body. An example would be:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>{
    "Message": {
      "Subject": "Email Unit Test",
      "Body": {
        "ContentType": "HTML",
        "Content": "Message body"
      },
      "ToRecipients": [
        {
          "EmailAddress": {
            "Address": "recipient@somehost.com"
          }
        }
      ],
      "Attachments": [
      ],
      "From": {
        "EmailAddress": {
          "Address": "shared_mailbox@domain.com"
        }
      },
      "Sender": {
        "EmailAddress": {
          "Address": "user@domain.com"
        }
      }
    },
    "SaveToSentItems": "false"
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Now, when I give user@domain.com 'Send As' and 'Send On Behalf Of' access to the shared mailbox this works. The recipient gets an email with the from field saying <strong>'user@domain.com On Behalf Of shared_mailbox@domain.com'</strong>. What I want however is for the email to appear as being sent from shared_mailbox only without the on behalf of user. To test this out further I removed the 'Send On Behalf Of' access and left 'Send As' access only. In the API I now get an error:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>{
      "error": {
          "code": "ErrorSendAsDenied",
          "message": "The user account which was used to submit this request does not have the right to send mail on behalf of the specified sending account., Cannot submit message."
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Interestingly though, in my Outlook client I can still send an email from the shared mailbox and it works as expected with no 'on behalf of' in the From field. I'm starting to wonder whether this is a limitation of the REST API however there is nothing in the Microsoft docs to suggest this.</p>
  
  <p>Has anyone had similar experiences with the REST API?</p>