Send Email from PowerShell in Office 365

Send Email from PowerShell in Office 365

In order to automate some tasks in Office 365 with PowerShell, sometimes you may want to send a confirmation email or a daily report by email. Luckily, there is an easy PowerShell cmdlet called “Send-MailMessage” that allows you to send an email with Exchange Server. You can also do that in Office 365, but you need to specify an important parameter: The Port number. Office 365 only accepts emails on Port 587 and secured by SSL.

Send Email from PowerShell

So the code to send an email is pretty easy:

If you want to learn more about PowerShell for Office 365, check out my Pluralsight course by clicking the banner below!

Send Email from PowerShell in Office 365

Follow me on Social Media and Share this article with your friends!

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
4.8/5 (10)

Please rate this

 
Comments

Is it possible to pass in a variable for the Subject the way you do for a body? It doesn’t look like it likes anything with a dollar sign in there.

I never tried it but it should work!

Leave a Reply