How to send mail to multiple user using powershell Script
For a project requirement I had to send mails to multiple users whose mailboxes had been moved to another database and whose mailbox Quota had been increased . I wrote a small Script for the same.
For the same, We need to populate a text files with users email id and run a bat file . Below is the code for the same . Save the below script in "sendmail.ps1" and create a bat file
with below line "powershell.exe .\sendmail.ps1" . Double click the bat file and mails will be sent to users
Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.E2010
$to1 = Get-Content .\abhishek.txt
$body += "Hello, `n `n"
$body += "Messaging team is pleased to report that your mailbox storage has been increased to 2 GB`n `n"
$body += "Thank you, `n "
$body += "Messaging Support Team"
foreach ($to2 in $to1)
{
Send-MailMessage -to $to2 -subject "Mailbox Storage has been increased" -Body $body -from abhishek.gupta3@mylab.com -smtpserver mapmail.mylab.com
}