0
我有一個從一個CSV文件導入聯繫人列表產生郵件PowerShell腳本:發送-返回MAILMESSAGE 4.4.1連接超時每10分鐘
# Get Credential
$Credential = & "C:\Powershell Scripts\Windows\Get-CredentialFromWindowsCredentialManager.ps1" ms.outlook.15:[email protected]
# Get Contacts
$contacts = Import-Csv -Path "C:\Powershell Scripts\Email\Contacts.csv"
# Compose Email for each contact
foreach($contact in $contacts)
{
Write-Output "Creating email for: $($contact.FirstName) $($contact.LastName)"
$To = "$($contact.FirstName) $($contact.LastName) <$($contact.Email)>"
$From = "My Email <[email protected]>"
$Subject = "$($contact.FirstName), I have a suggestion for you!"
$Body = "<html></html>"
$SMTPServer = "smtp.office365.com"
$Port = 587
Send-MailMessage -To $To -From $From -Subject $Subject -SmtpServer $SMTPServer -Credential $Credential -UseSsl -Body $Body -BodyAsHtml -Port $Port
# Due to the Message Send rate limit (30 per minute) I added this to slow the rate down
Start-Sleep -Seconds 10
}
每隔10分鐘,我得到以下SMTP例外:
Send-MailMessage : Service not available, closing transmission channel. The server response was: 4.4.1 Connection timed out. Total session duration: 00:10:08.3716645 At C:\Powershell Scripts\Email\SendEmail.ps1:17 char:2 + Send-MailMessage -To $To -From $From -Subject $Subject -SmtpServer $SMTPServer ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
是否有任何設置可以修改或更改代碼,防止出現這種情況?
你是怎麼【考證】(https://social.technet.microsoft.com/Forums/exchange/EN-US/46095334-d788-4b4e-b790-4336a4174c9c/PowerShell的sendmailmessage-TIME-OUT-441-錯誤?論壇= exchange2010)? –
我只發送了大約100-200封電子郵件(遠低於下面文章中概述的Office 365 E1計劃的限制)。 https://technet.microsoft.com/en-us/library/exchange-online-limits.aspx – EdC