CDO.Message原因。发送脚本执行超时 [英] CDO.Message .Send causes script execution timeout

查看:1004
本文介绍了CDO.Message原因。发送脚本执行超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code:

Set myMailanon = CreateObject("CDO.Message")
myMailanon.MimeFormatted = True

Set myConfanon = Server.CreateObject("CDO.Configuration")
Set objBPanon = myMailanon.AddRelatedBodyPart("http://www.foo.bar/img/logo1.jpg", "http://www.foo.bar/img/logo1.jpg", CdoReferenceTypeName)
objBPanon.Fields.Item("urn:schemas:mailheader:Content-ID") = "<http://www.foo.bar/img/logo1.jpg>" 
objBPanon.Fields.Update 
ConfURLanon = "http://schemas.microsoft.com/cdo/configuration/"

with myConfanon        
  .Fields.Item(ConfURLanon & "sendusing") = 2        
  .Fields.Item(ConfURLanon & "smtpserver") = "smtp.foo.bar"        
  .Fields.Item(ConfURLanon & "smtpserverport") = 25     
  .Fields.Item(ConfURLanon & "smtpusessl") = false
  .Fields.Item(ConfURLanon & "smtpauthenticate") = 1
  .Fields.Item(ConfURLanon & "sendusername") = "foo@bar.com"
  .Fields.Item(ConfURLanon & "sendpassword") = "foobarpass"
  .Fields.Update
end with

with myMailanon
  .Subject='Foo!! Bar!!'
  .From='Foo!! Bar!! <foo@bar.com>'      
  .To='foo@bar.com,bar@foo.com'      
  txt="This is foo... bar... text... SPARTAAAAAAAAA"
  .HTMLBody = txt
  Set .Configuration = myConfanon   
  On Error Resume Next 
  .Send      
end with

问题是,这code,运行100次,将工作30和70失败随机。
和不及格我的意思是,这将导致脚本执行超时。

Problem is that this code, run 100 times, will work 30 and fail 70. Randomly. And by "fail" I mean that it will cause Script execution timeout.

一行注释行之后,我得到的错误出自。发送的结论。
但为什么?任何想法?

After commenting line by line, I got to the conclusion that the error comes from ".Send". But why? Any ideas?

问候

推荐答案

有没有什么不妥code(athough CdoReferenceTypeName 看起来有点可疑但可能只是变量命名差)。这可能仅仅是因为SMTP服务器正忙,因此正在采取一些时间来处理发送。

There isn't anything wrong with code (athough CdoReferenceTypeName looks a little suspect but that could be just poor variable naming). It could just be that the SMTP server is busy and is therefore taking a while to process the send.

您可以为您在IIS管理器中的ASP功能指定的脚本超时值。默认情况下它应为90秒,但也许是其被设置为由于某些原因低值。

You could check the Script Time-out value specified for the ASP feature in IIS manager. By default it should be 90 seconds but perhaps its been set to a low value for some reason.

您可以通过在code指定它增加你的脚本有时间。

You can increase the amount of time you script has by specifying it in your code.

Server.ScriptTimeout = 300

这将使你的脚本有5分钟。这很可能会掩盖你的Web服务器和SMTP服务器之间的一些设置问题,但它可能会提高成功率。 OTH你可能会得到同样的结果,但70%的故障需要更长的时间出现。

Which would give your script a 5 minutes. This may well be masking some set up problem between your web server and SMTP server but it may increase the success rate. OTH you may get the same results but the 70% failures take longer to occur.

不管是什么原因,我不认为这是你的code。

Whatever the cause I don't think its your code.

这篇关于CDO.Message原因。发送脚本执行超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆