Powershell send-mailmessage - email to multiple recipients

前端 未结 7 2079
小蘑菇
小蘑菇 2020-11-29 07:10

I have this powershell script to sending emails with attachments, but when I add multiple recipients, only the first one gets the message. I\'ve read the documentation and s

7条回答
  •  萌比男神i
    2020-11-29 07:39

    You must first convert the string to a string array, like this:

    $recipients = "Marcel ,Marcelt "
    [string[]]$To = $recipients.Split(',')
    

    Then use Send-MailMessage like this:

    Send-MailMessage -From "primasfrb@nbs.sk" -To $To -subject "New files" -body "$teloadmin" -BodyAsHtml -priority High -dno onSuccess, onFailure -smtpServer 192.168.170.61
    

提交回复
热议问题