我不能得到這個在Windows工作7客戶端使用PowerShell 2發送郵件使用PowerShell的Windows 7
$smtpServer = "smtp.example.com"
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "[email protected]"
$msg.ReplyTo = "[email protected]"
$msg.To.Add("[email protected]")
$msg.subject = "My Subject"
$msg.body = "This is the email Body."
$smtp.Send($msg)
我收到寫着「異常調用‘與‘1’參數發送’失敗時發送異常郵件「 任何人有任何想法? 我已經嘗試了Send-MailMessage,但它也失敗了,如果我在基於Windows的服務器上運行該命令,它的執行效果很好。 我爲這些過程使用相同的帳戶。
請顯示您正在獲取的確切錯誤。你可以連接到'$ smtpServer'嗎?用'telnet smtp.xxxx.com 25'檢查。 –
顯示你得到的確切的錯誤,特別是當你使用'Send-MailMessage'(這比'Net.Mail'更可取)。 – alroc