[英]Powershell email sending with an error
我正在尝试使用PowerShell函数Send-MailMessage发送电子邮件,并且遇到了许多非常奇怪的问题:
Send-MailMessage : A positional parameter cannot be found that accepts argument 'True'.
Send-MailMessage -Body $body -BodyAsHtml $true -From "senderadress@safrangroup.com" -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中指定的人了 ...我不明白为什么我不能添加此-To参数,最重要的是为什么即使在发送邮件时也是如此有一个错误...
任何想法 ?
如果检查语法
Get-Command Send-MailMessage -Syntax
您添加的参数[-BodyAsHtml]
是开关类型,并且不期望$true
值。 您可以指定-BodyAsHtml:$true
Send-MailMessage [-To] <string[]> [-Subject] <string> [[-Body] <string>] [[-SmtpServer] <string>] -From <string> [-Attachments <string[]>] [-Bcc <string[]>] [-BodyAsHtml] [-Encoding <Encoding>] [-Cc <string[]>] [-DeliveryNotificationOption <DeliveryNotificationOptions>] [-Priority <MailPriority>] [-Credential <pscredential>] [-UseSsl] [-Port <int>] [<CommonParameters>]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.