Powershell send-mailmessage - 向多个收件人发送电子邮件 [英] Powershell send-mailmessage - email to multiple recipients
本文介绍了Powershell send-mailmessage - 向多个收件人发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个 powershell 脚本来发送带附件的电子邮件,但是当我添加多个收件人时,只有第一个收到邮件.我已经阅读了文档,但仍然无法弄清楚.谢谢
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 still can't figure it out. Thank you
$recipients = "Marcel <marcel@turie.eu>, Marcelt <marcel@nbs.sk>"
Get-ChildItem "C:\Decrypted\" | Where {-NOT $_.PSIsContainer} | foreach {$_.fullname} |
send-mailmessage -from "primasfrb@nbs.sk" `
-to "$recipients" `
-subject "New files" `
-body "$teloadmin" `
-BodyAsHtml `
-priority High `
-dno onSuccess, onFailure `
-smtpServer 192.168.170.61
推荐答案
$recipients = "Marcel <marcel@turie.eu>, Marcelt <marcel@nbs.sk>"
是 string
的类型,您需要传递给 send-mailmessage
一个 string[]
类型(数组):
is type of string
you need pass to send-mailmessage
a string[]
type (an array):
[string[]]$recipients = "Marcel <marcel@turie.eu>", "Marcelt <marcel@nbs.sk>"
我认为不强制转换为 string[] 可以完成 powershell 的强制规则:
I think that not casting to string[] do the job for the coercing rules of powershell:
$recipients = "Marcel <marcel@turie.eu>", "Marcelt <marcel@nbs.sk>"
是 object[]
类型但可以做同样的工作.
is object[]
type but can do the same job.
这篇关于Powershell send-mailmessage - 向多个收件人发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文