I getting an error try to use this piece of code.
Error:
Send-MailMessage : An invalid character was found in the mail header: ','.
Thanks.
$messageParameters = @{
From = "xxxx@xxx.com"
To = "xxx@xxx.com,yyy@yyy.com,zzz@zzz.com"
Subject = "DBLocks "
Body = "Job Status"
SMTPServer = "xxxxxx"
Attachments = $file.FullName}
Send-MailMessage @messageParameters
September 22, 2021 at 4:01 pm
The to list needs to be an array @() not a comma separated string 🙂
September 22, 2021 at 4:21 pm
I tried something like this then used $ToString
$ArrayOfStrings = @("xxxx@.xxxxcom","yyyyy@yyyy.com","zzzz@zzzz.com")
$ToString = $ArrayOfStrings -join ","
September 22, 2021 at 4:28 pm
Don't convert it to a string at all, the to parameter should just be the array if it's going to multiple addresses.
September 22, 2021 at 4:39 pm
can't get it to work. Would you mind supplying me the syntax.
Many Thx.
This works fine for me,
$messageParameters = @{
From = "xxxx@xxx.com"
To = @("asfadsf@dsdasf.com", "djshgfkdhas@hcbvmxc.com")
Subject = "DBLocks "
Body = "Job Status"
SMTPServer = "SMTPSERVER"
}
Send-MailMessage @messageParameters
September 22, 2021 at 4:53 pm
I thought that is what I had, but must have a typo or something.
Thanks Again that worked!!!.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply