我正在尝试制作一行Send-MailMessage命令。我出来了这段代码:
Send-MailMessage -SmtpServer 'smtp.gmail.com' -Port 587 -From 'my_email@gmail.com' -To 'someone_email@gmail.com' -Subject 'Test' -Body 'Body' -UseSsl -Credential (New-Object System.Management.Automation.PSCredential('my_email@gmail.com', (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 'my_email@gmail.com' -To 'someone_email@gmail.com' -Subject 'Test' -Body 'Body' -UseSsl -Credential (New-Object system.Management.Automation.PSCredential('my_email@gmail.com', (ConvertTo-SecureString 'my_password' -AsPlainText -Force)))
+ CategoryInfo : InvalidArgument: (:) [Send-MailMessage], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SendMailMessage
请帮助我!!
答案 0 :(得分:3)
在PowerShell V 3.0之前,Port参数才出现。下载并安装最新的Windows Management Framework并进行试用。