[英]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.