2017-11-18 2 views
1

1行のSend-MailMessageコマンドを作成しようとしています。私はこのコードで出てきた:Send-MailMessageコマンドが1行で動作しない

Send-MailMessage -SmtpServer 'smtp.gmail.com' -Port 587 -From '[email protected]' -To '[email protected]' -Subject 'Test' -Body 'Body' -UseSsl -Credential (New-Object System.Management.Automation.PSCredential('[email protected]', (ConvertTo-SecureString 'my_pass' -AsPlainText -Force))) 

そして、私はこのエラーを得た:

Send-MailMessage : A parameter cannot be found that matches parameter name 'Port'. 
At G:\Send_email\TEST-SEND-EMAIL.ps1:1 char:23 
+ Send-MailMessage -Port <<<< 587 -SmtpServer 'smtp.gmail.com' -From '[email protected]' -To '[email protected]' -Subject 'Test' -Body 'Body' -UseSsl -Credential (New-Object system.Management.Automation.PSCredential('[email protected]', (ConvertTo-SecureString 'my_password' -AsPlainText -Force))) 
+ CategoryInfo   : InvalidArgument: (:) [Send-MailMessage], ParameterBindingException 
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SendMailMessage 

私を助けてください!

答えて

3

Portパラメータは、PowerShellのV 3.0までは表示されませんでした。最新のWindows Management Frameworkをダウンロードしてインストールしてみてください。

関連する問題