Hello All,
Can someone let me know how to send mail to multiple users using send-mailmessage command and I have the users email address in a text file.
All the email addresses mentioned should be recipients of single mail.
Please help…Thanks
Hello All,
Can someone let me know how to send mail to multiple users using send-mailmessage command and I have the users email address in a text file.
All the email addresses mentioned should be recipients of single mail.
Please help…Thanks
I notice you have already open a topic.
you can try to use a foreach loop
$mails=Import-Csv -Path .\mail.txt
foreach($mail in $mails){
Send-MailMessage -From "abcd@gmail.com" to "$mails" -Subject "Your subject" -Body "You Boday" -SmtpServer "your smtpserver"
}
Using the example from Chen.Chen
$recipients = Get-Content -Path .\mail.txt
Send-MailMessage -From "abcd@gmail.com" -To $recipients -Subject "Your subject" -Body "Your body" -SmtpServer "your smtpserver"