Print Page | Close Window

Continue script before function completes

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=15321
Printed Date: 30 March 2026 at 6:55am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Continue script before function completes
Posted By: JohnKn
Subject: Continue script before function completes
Date Posted: 01 June 2005 at 11:09am
Is it possible to have a script call a function or sub and continue before that function or sub finishs it's task? Here's the problem I'm having and what I'm trying to solve. My hosts SMTP server is being horribly slow, on the order of 10-15 seconds to send a simple email. As you can guess with the forum if it has to send 10 notices on a post it can take as much as 2 minutes for the post_message.asp script to complete.

Is there any way to call the email function, or wrap the email notification section in a function or sub, to queue up the emails and finish the post_message.asp script before the mails are all sent?

I'm not sure if it's even possible to execute ASP/vb script in a non linear fashion like that.

Thanks for any suggestions (other than changing mail servers, I know that works but isn't a viable option right now).

John



Replies:
Posted By: dj air
Date Posted: 01 June 2005 at 11:13am
i dont think you can do what you want,.

if it is that slow it most likely is a big distance between the web server and mail server, as this does make the forum slower during postings.,

who is your host?, i would recommend looking for somewhere else if it is being that slow , it shouldn't take that long.


Posted By: JohnKn
Date Posted: 01 June 2005 at 12:21pm
It's a problem with their mail server that they don't want to admit too, it didn't used to be that way. There isn't really a large distance between the web server, hosted on my cable connection, and the ISPs mail server. It used to be much quicker, say 1 second, as you would expect.

I can send mail through my own SMTP server but then I run into overly agressive spam filters that think they know every valid IP address and so on.

I'm thinking the only way to do this, if it's even possible, would be to spawn a seperate thread, which may not be possible or may require a ISAPI control. It would probably be simpler to drive down to the cable company and fix their SMTP problem for them. LOL

Thanks dj air.


Posted By: JohnKn
Date Posted: 01 June 2005 at 1:38pm
It does seem to be possible using MSMQ, next question is whether it's worth the effort or not for me to do it in this case.

Here is an interesting PDF on a solution that creates an asyncronous emailer:

http://www.digievo.co.uk/articles/asyncmailer/asyncmailer.pdf - http://www.digievo.co.uk/articles/asyncmailer/asyncmailer.pdf


Posted By: Gullanian
Date Posted: 01 June 2005 at 3:19pm
It's easy to multithread in .net as I understand, but not ASP.


Posted By: Mart
Date Posted: 01 June 2005 at 3:41pm
Yeah, in .net you can just call the sub asynchronously. You could do all your code for that page inside a VB6 COM Component and use threading, but that could mean a messy deployment.


Posted By: JohnKn
Date Posted: 01 June 2005 at 4:13pm
It turns out you can also do it using XMLHTTP by calling another script. You can use xmlHTTP to do a post or get of another script and not have the initial page wait for a response. While this method works to get it to work with WebWiz would mean some passing all of the sendmail parameters to the new script so it could loop through the people to send email to.

Here is the code to call script2 from script1 and not have script1 wait for script2 to finish it's tasks.

  Response.Buffer = True
  Dim objXMLHTTP, xml
  Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
     
  xml.Open "GET", "http://localhost/somescript.asp", True
  Call xml.Send()

  On Error Resume Next
 
  'Wait for 1 second to see if we've not gotten the data yet
  If xml.readyState <> 4 then
    xml.waitForResponse 1 ' After 1 second move on with the script
  End If

  Set xml = Nothing


Posted By: dpyers
Date Posted: 01 June 2005 at 7:32pm
You might want to see if they allow you to use localhost for a mail server.
 
Some mail components also support queued mail. I don't recall offhand which ones do and which ones don't but for some reason I thing that AspEmail might. Find out which components your host supports and check the component site for details on queued mail. Usually just requires setting another component option or two.


-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net