Send an email with GraphAPI and PowerShell

Send an email with GraphAPI and PowerShell

To follow on from this blog post where we interrogated the GraphAPI to obtain information regarding the user object which invoked the call. We are going to use GraphAPI and PowerShell to Send an email, I know what you’re say, “But Steve I can just use the Send-MailMessage commandlet” which is true, but what the this solution gets you is a record in your Sent Items of the email. All of this without even needing to think about setting up anything to do with SMTP.
So the major difference from the last script to this one is that we need to construct a JSON object, which we then POST to GraphAPI, rather then using a GET function like we did previously. An example of this is:

In my sample I have kept it simple with a single recipient, a Subject, and body. But there is a vast amount of information which you can define for the email your sending, you can find more about it here.
For a full copy of script please look here

Good Luck


Leave a Reply