Welcome to an article on How to Send Email using PowerShell Script.
Sometimes as per our requirement, we need to send email in a process when our PowerShell script executes so we don’t need an external tool to do that. You can send emails using PowerShell.
How? Let’s see it.
- Open Windows PowerShell Modules as an Administrator.

Code
$mymail = New-Object System.Collections.Specialized.StringDictionary
#Add the email address of the user you want to send email to.
$mymail.Add("to", " [email protected] ")
#Add the email address of the user you want to send email as cc.
$mymail.Add("cc", "[email protected]")
#Add the email address of the user you want to send email as bcc.
$mymail.Add("bcc", "[email protected]")
#Add the email address of the user you want to get email from.
$mymail.Add("from", "from@ webdomain.com ")
#provide a subject
$mymail.Add("subject", "This is Awesome")
#provide a type of your content
$mymail.Add("content-type", "text/html")
#provide the body of your email
$bodyText = "I am sending email using PowerShell"
#Apply the function to send email
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web, $mymail, $bodyText)
- Save the above code in a notepad as .ps1 file.
- Run the code on the Windows PowerShell Modules.
- The desired recipients will receive an email.
It will be so quick that you don’t take much time and effort on this, thereby saving a lot of time and effort.

Manpreet SinghPosted Aug 18, 2016, 6:13 PM
Kvbharat Bhushan, do you have SMTP configured on the server where you are trying to run this script?
Guest UserPosted Aug 18, 2016, 2:09 AM
$mymail = New-Object System.Collections.Specialized.StringDictionary #Add the email address of the user you want to send email to. $mymail.Add("to", "[email protected]") #Add the email address of the user you want to send email as cc. $mymail.Add("cc", "[email protected]") #Add the email address of the user you want to send email as bcc. $mymail.Add("bcc", "[email protected]") #Add the email address of the user you want to get email from. $mymail.Add("from", "[email protected]") #provide a subject $mymail.Add("subject", "This is Awesome") #provide a type of your content $mymail.Add("content-type", "text/html") #provide the body of your email $bodyText = "I am sending email using PowerShell" #Apply the function to send email [Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web, $mymail, $bodyText)
Guest UserPosted Aug 18, 2016, 2:07 AM
It didn't work buddy. I am supposed to receive a mail to my Outlook based on this code but I didn't receive. Please let me know why is not happening? Here is the below code which I have saved as ps1 file and made Windows PowerShell to run it but no luck!!