Send Email using PowerShell

If you have to send email using PowerShell Command., then use SPUtility object to meet your purpose. Here is the code below.

$web = Get-SPWeb -Site
http://mysite
$headers = New-Object System.Collections.Specialized.StringDictionary
$message.To.Add("[email protected]")    
$message.Cc.Add("[email protected]")      
$headers.Add("from", "[email protected]")
$headers.Add("subject", "Test Email Subject")
$headers.Add("content-type", "text/html")
$bodyText = "Hello C# Corner?"
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web, $headers, $bodyText)
Ebook Download
View all
Learn
View all