我有这个 powershell 脚本来发送带有附件的电子邮件,但是当我添加多个收件人时,只有第一个收件人收到消息。我已经阅读了文档,但仍然无法弄清楚。谢谢
$recipients = "Marcel <[email protected] /cdn-cgi/l/email-protection>, Marcelt <[email protected] /cdn-cgi/l/email-protection>"
Get-ChildItem "C:\Decrypted\" | Where {-NOT $_.PSIsContainer} | foreach {$_.fullname} |
send-mailmessage -from "[email protected] /cdn-cgi/l/email-protection" `
-to "$recipients" `
-subject "New files" `
-body "$teloadmin" `
-BodyAsHtml `
-priority High `
-dno onSuccess, onFailure `
-smtpServer 192.168.170.61
$recipients = "Marcel <[email protected] /cdn-cgi/l/email-protection>, Marcelt <[email protected] /cdn-cgi/l/email-protection>"
是类型string
你需要传递到send-mailmessage
a string[]
类型(数组):
[string[]]$recipients = "Marcel <[email protected] /cdn-cgi/l/email-protection>", "Marcelt <[email protected] /cdn-cgi/l/email-protection>"
我认为不转换为 string[] 可以完成 powershell 的强制规则:
$recipients = "Marcel <[email protected] /cdn-cgi/l/email-protection>", "Marcelt <[email protected] /cdn-cgi/l/email-protection>"
is object[]
类型,但可以完成相同的工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)