How to Send Email from Powershell in SharePoint 2010/2013/2016/2019 & Office 365?

Hello SharePointers,

Below are the Powershell script to send email from powershell in SharePoint 2010/2013/2016/2019 & Office 365.

$DicObject = New-Object System.Collections.Specialized.StringDictionary
$DicObject .Add(“to”,”you@yourdomain.com”)
$DicObject .Add(“from”,”fromname@yourdomain.com”)
$DicObject .Add(“subject”,”Test Email”)
$web = Get-SPWeb http://yourdomain.com
$body = “This is a test email Friends”

try {
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web,$DicObject ,$body)
}
finally {
$w.Dispose()
}

Happy SharePointing 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *