首页 > 解决方案 > Windows 10 的 powershell 中的电子邮件功能操作已超时

问题描述

我在运行我的 powershell 脚本时收到“Send-MailMessage:操作已超时”操作。下面是我得到的例外

Send-MailMessage : The operation has timed out.
At C:\Users\f1ym41a\Documents\email.ps1:8 char:1
+ Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject -Body $Body -Smtp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpExcept
   ion
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage

我正在使用的代码或我的 powershell 脚本

$From = "user@domain.com"
$To = "user@domain.com"
$Cc = "user@domain.com"
$Subject = "Here's the Email Subject"
$Body = "This is what I want to say"
$SMTPServer = "someserver"
$SMTPPort = "25"
Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject -Body $Body -SmtpServer $SMTPServer -port $SMTPPort –DeliveryNotificationOption OnSuccess

谁能帮我解决为什么我会出现超时异常?

标签: powershell

解决方案


推荐阅读