title: The remote server returned an error: (404) Not Found when trying to send an email using MS graph API
body: <p>I have followed the steps on this page <a href="https://adamtheautomator.com/azure-send-email" rel="nofollow noreferrer">https://adamtheautomator.com/azure-send-email</a>. What I am trying to do is send an email out from a Ps script.</p>
  <p>I get the error message below.</p>
  <pre><code>VERBOSE: POST https://graph.microsoft.com/v1.0/users/xxxxxxxxx@domain.com/sendMail with -1-byte payload
  Invoke-RestMethod : The remote server returned an error: (404) Not Found.
  At line:65 char:1
  + Invoke-RestMethod @params -Verbose
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
  </code></pre>
  <p>What have I done ?</p>
  <p>Did some research and found a similar question, <a href="https://stackoverflow.com/questions/59137611/how-to-get-mailbox-for-my-new-azure-active-directory-domain">How to get mailbox for my new Azure Active Directory Domain?</a></p>
  <p>At the moment I am trying to send the email as myself (using my email address). I do however have a mailbox created for alerts, so I could send as that user, the issue I have here is that with the 404 error it means the endpoint is incorrect.</p>
  <pre><code>  &quot;URI&quot;         = &quot;https://graph.microsoft.com/v1.0/users/$fromAddress/sendMail&quot;
  </code></pre>
  <p>I am unsure as to what to use as the sender email address, the <a href="https://stackoverflow.com/questions/59137611/how-to-get-mailbox-for-my-new-azure-active-directory-domain">link</a> suggests that the user sending out the email alert should <strong>have a mailbox. You need an O365 subscription for your AAD, then you can assign the license to the users which you need a mailbox.</strong></p>
  <p>We use O365, I have a mailbox, how can i tell if AAD has a o365 subscription ? How can i tell that i am using the correct sender email address, during my research I saw examples using name@domain.com and in some cases name.domain.onmicrosoft.com. I have tried several combinations to no avail, this should not be a guessing game, how can I be sure of using the right details ?</p>