【问题标题】:Send-MailMessage command in a single line not working单行中的 Send-MailMessage 命令不起作用
【发布时间】:2017-11-18 03:30:48
【问题描述】:

我正在尝试制作单行 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

请帮帮我!!

【问题讨论】:

    标签: powershell sendmessage


    【解决方案1】:

    Port 参数直到 PowerShell V 3.0 才出现。下载并安装最新的 Windows Management Framework 并试用。

    【讨论】:

      猜你喜欢
      • 2019-06-05
      • 2023-03-19
      • 2014-05-12
      • 1970-01-01
      • 2020-01-30
      • 1970-01-01
      • 2012-05-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多