469,625 Members | 908 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

ASP / CDOSYS - Performance issue

I'm hosted on a shared server with Godaddy.com... I have several forms on my website that all use the same ASP file to send out my forms..
It worked fine for a long time, but now the forms send to my e-mail arrive after a few hours instead of instantly.
Calling Godaddy did not help as they stated all is working fine (no delays) on their end and refuse to help with custom scripts..

My emails are also hosted by godaddy like my website.

Hopefully someone here can have a look at my code and see why I might have such huge delays?
Note:
The delays seem to happen when using CDOSYS... I'm also setting up a shopping cart (ProductCart) and when using the CDOSYS function for their email script it has also a huge delay, while setting it to CDO it arrives within minutes...
I do not get any errors, all seems to go fine and mail does arrive after a few hours.

Here's the code (personal info marked out of cos):

Expand|Select|Wrap|Line Numbers
  1. <%
  2. option explicit
  3. dim pde : set pde = createobject("scripting.dictionary")
  4.  
  5. pde.add "%mailing%", "email1@myserver.com"
  6. pde.add "%webmaster%", "email2@myserver.com"
  7. pde.add "%info%", "email3@myserver.com"
  8. pde.add "%email%", "email4@myserver.com"
  9.  
  10. function getTextFromFile(path)
  11. dim fso, f, txt
  12. set fso = createobject("Scripting.FileSystemObject")
  13. if not fso.fileexists(path) then
  14. getTextFromFile = ""
  15. exit function
  16. end if
  17. set f = fso.opentextfile(path,1)
  18. if f.atendofstream then txt = "" else txt = f.readall
  19. f.close
  20. set f = nothing
  21. set fso = nothing
  22. getTextFromFile = txt
  23. end function
  24.  
  25. dim redir, mailto, email, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode
  26. redir = request.form("redirect")
  27. mailto = request.form("mailto")
  28. if pde.exists(mailto) then mailto = pde(mailto)
  29. cc = request.form("cc")
  30. bcc = request.form("bcc")
  31. email = request.form("email")
  32. if email = "" then email = pde("%email%")
  33. subject = request.form("subject")
  34. message = request.form("message")
  35. template = request.form("template")
  36. testmode = lcase(request.form("testmode"))="no"
  37.  
  38. if len(template) > 0 then template = getTextFromFile(server.mappath(template))
  39. if len(template) > 0 then usetemplate = true else usetemplate = false
  40. dim msg : set msg = server.createobject("CDO.Message")
  41. msg.subject = subject
  42. msg.to = mailto
  43. msg.from = email
  44. if len(cc) > 0 then msg.cc = cc
  45. if len(bcc) > 0 then msg.bcc = bcc
  46.  
  47. if not usetemplate then
  48. body = body & message & vbcrlf & vbcrlf
  49. else
  50. body = template
  51. end if
  52. for each item in request.form
  53. select case item
  54. case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode"
  55. case else
  56. if not usetemplate then
  57. if item <> "email" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf
  58. else
  59. body = replace(body, "[$" & item & "$]", replace(request.form(item),vbcrlf,"<br>"))
  60. end if
  61. end select
  62. next
  63.  
  64. if usetemplate then 'remove any leftover placeholders
  65. dim rx : set rx = new regexp
  66. rx.pattern = "\[\$.*\$\]"
  67. rx.global = true
  68. body = rx.replace(body, "")
  69. end if
  70.  
  71. if usetemplate and lcase(request.form("html")) = "yes" then
  72. msg.htmlbody = body
  73. else
  74. msg.textbody = body
  75. end if
  76. if testmode then
  77. if lcase(request.form("html")) = "yes" then
  78. response.write "<pre>" & vbcrlf
  79. response.write "Mail to: " & mailto & vbcrlf
  80. response.write "Mail from: " & email & vbcrlf
  81. if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
  82. if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
  83. response.write "Subject: " & subject & vbcrlf & string(80,"-") & "</pre>"
  84. response.write body
  85. else
  86. response.write "<html><head><title>Sendmail.asp Test Mode</title></head><body><pre>" & vbcrlf
  87. response.write "Mail to: " & mailto & vbcrlf
  88. response.write "Mail from: " & email & vbcrlf
  89. if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
  90. if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
  91. response.write "Subject: " & subject & vbcrlf & vbcrlf
  92. response.write string(80,"-") & vbcrlf & vbcrlf & "<span style=""color:blue;"">"
  93. response.write body & "</span>" & vbcrlf & vbcrlf
  94. response.write string(80,"-") & vbcrlf & "**END OF EMAIL**</pre></body></html>"
  95. end if
  96. else
  97. msg.send
  98. response.redirect redir
  99. end if
  100. set msg = nothing
  101. %>
I also tried adding these lines (and combinations) without any better results:

Expand|Select|Wrap|Line Numbers
  1. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  2. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay-hosting.secureserver.net"
  3. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 3535
  4. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") =1
  5. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "email1@myserver.com"
  6. msg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "abc1234"
Here's a sample of what's used in the forms:

Expand|Select|Wrap|Line Numbers
  1. <form action="/sendmail_cdo.asp" method="post" name="SampleForm" id="SampleForm">
  2. <input type="hidden" name="redirect" value="http://www.myserver.com/thanks.htm">
  3. <input name="mailto" type="hidden" id="mailto" value="%webmaster%">
  4. <input name="subject" type="hidden" id="subject" value="Website Form Submission: Sample form from website">
In the html template used with the form, I use [$form_fieldname$] to display the values entered in the forms.


Anyone any ideas why there might be this huge delay and/or does anyone know how to change this to CDO instead of CDOSYS (as this worked for the shopping cart)?
May 1 '08 #1
1 1245
jhardman
3,406 Expert 2GB
Anyone any ideas why there might be this huge delay and/or does anyone know how to change this to CDO instead of CDOSYS (as this worked for the shopping cart)?
CDO is the same as CDOSYS, In the code it is just CDO, so some people call it CDO, but the official name is CDOSYS. (Unless you mean CDONTS in which case this is different and you shouldn't use CDONTS any more.) So I guess I'm saying I don't understand the question.

Jared
May 5 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Mortisus | last post: by
17 posts views Thread by 57R4N63R | last post: by
5 posts views Thread by Varangian | last post: by
10 posts views Thread by shsandeep | last post: by
7 posts views Thread by Andres Rormoser | last post: by
8 posts views Thread by worldofrugs | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.