0

有没有办法我们可以使用发送邮件消息发送巨大的附件,我尝试了下面的代码片段,但它总是超时。请注意,它是一个测试实验室设置,邮箱相关属性设置为无限制,所以我没有从管理点丢失任何东西.

    PS C:\Users\administrator.SMETEST> Send-MailMessage -From "loadtest@smetest.com" -To "loadtestuser4@smetest.com" -SmtpSe
    rver HUB -Subject hi -Attachments "C:\officesuite2010sp1-kb2460049-x86-fullfile-en-us.exe" -Verbose

    Send-MailMessage : The operation has timed out.
    At line:1 char:17
    + Send-MailMessage <<<< -From "loadtest@smetest.com" -To "loadtestuser4@smetest.com" -SmtpServer HUB -Subje
    ct hi -Attachments "C:\officesuite2010sp1-kb2460049-x86-fullfile-en-us.exe" -Verbose
    + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpExcept
    ion
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage

尝试了以下方法,它仍然超时

PS C:\Users\administrator.SMETEST> Send-MailMessage -From "loadtest@smetest.com" -To "loadtestuser4@smetest.com" -SmtpSe
rver HUB -Subject hi -Attachments "C:\ADCheck.ps1"
PS C:\Users\administrator.SMETEST> Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -erroraction silentlyCont
inue
PS C:\Users\administrator.SMETEST> $file = "C:\officesuite2010sp1-kb2460049-x86-fullfile-en-us.exe"
PS C:\Users\administrator.SMETEST> $smtpServer = "HUB"
PS C:\Users\administrator.SMETEST> $att = new-object Net.Mail.Attachment($file)
PS C:\Users\administrator.SMETEST> $msg = new-object Net.Mail.MailMessage
PS C:\Users\administrator.SMETEST> $smtp = new-object Net.Mail.SmtpClient($smtpServer)
PS C:\Users\administrator.SMETEST> $msg.From = "loadtest@smetest.com"
PS C:\Users\administrator.SMETEST> $msg.To.Add("loadtestuser4@smetest.com")
PS C:\Users\administrator.SMETEST> #$msg.To.Add("administrator2@test.com")
PS C:\Users\administrator.SMETEST> $msg.Subject = "Notification from email server"
PS C:\Users\administrator.SMETEST> $msg.Body = "Attached is the email server mailbox report"
PS C:\Users\administrator.SMETEST> $msg.Attachments.Add($att)
PS C:\Users\administrator.SMETEST> $smtp.Send($msg)
Exception calling "Send" with "1" argument(s): "The operation has timed out."
At line:1 char:11
+ $smtp.Send <<<< ($msg)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

PS C:\Users\administrator.SMETEST> $att.Dispose()
PS C:\Users\administrator.SMETEST>
4

0 回答 0