Send-MailMessage with multiple receipients input from file

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"
}


Yes @Chen.Chen

If for each loop is being used, then all users are not included in single mail

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"