Hi everyone ,
I have been trying to follow the blog on this site to send emails to multiple users with no Success. I hope someone could offer me some advice on how to change my scripts.
Currently have email notification working fine for 1 user with this script:
#############################################################################
# Add function to send e-mail
#############################################################################
Function Send-Email([String] $smtpServer, [String] $from, [String] $to, [String] $subject, [String] $body, [String] $userName, [String] $password)
{
if ($userName.Length > 0 ) {
$credential=New-Object System.Net.NetworkCredential -argumentList $userName,$password
Send-MailMessage -From $from -To $to -Subject $subject -Body $body -SmtpServer $smtpServer -Credential $credential
}
else
{
Send-MailMessage -From $from -To $to -Subject $subject -Body $body -SmtpServer
$smtpServer
}
}
and define SMTP details here.
###########################################
# Define the default SMTP server
###########################################
$smtpServer="10.xxx.xx.01"
$fromAddress="yyyyy.pppppp.com"
$toAddress="xxxxxx.tttttt.com"
$smtpUserName=""
$smtpPassword=""
Would really appreciate any advice on how to change the above to allow me to send to multiple addresses. As I mentioned I have tried amending the script my self with 100% failure so far. :-(
Many thanks everyone.