我试图用PowerShell的功能发送-MAILMESSAGE发送电子邮件,和我在的各种问题面前是很奇怪:PowerShell的电子邮件错误发送
- 所有的第一,当我在PowerShell ISE中编写此函数时,不会提出参数- 至。如果我尝试添加也无妨,如果有以下错误
Send-MailMessage : A positional parameter cannot be found that accepts argument 'True'.
- 所以绕过这个问题,我发现我可以使用-Cc参数发送电子邮件给某人。所以我到发送-MAILMESSAGE调用看起来像下面
Send-MailMessage -Body $body -BodyAsHtml $true -From "[email protected]" -Cc $recipient -Priority High - Encoding ([System.Text.Encoding]::UTF8) -SmtpServer "my.smtp.server" -Subject ("My subject") -Attachments "RESSOURCES/logo.png"
的问题是,当该行执行时,它抛出一个错误:
Send-MailMessage : The specified string is not in the form required for an e-mail address.
但这里最奇怪的是,邮件已发送到-Cc中指定的人员...我不明白为什么我不能添加这个- 到的说法,最重要的是为什么它发送的消息,即使有错误...
任何想法?
什么是'$ recipient'的全部价值? – gravity
我无法发布实际价值,但它完全像“[email protected]” –
不确定它是唯一的问题,但是'-BodyAsHtml $ true'(afaik)错误,它应该只是'-BodyAsHtml'或'-BodyAsHtml:$ true' – whatever