0

I'm at a loss here. I'm coding a forum and users will have the ability to be notified via email when someone replies to a thread they are involved in. So, user A, B, and C are all active on a thread and want to be notified when there is a post. When user D comes along and posts to the thread, I need to send an email to A, B, and C.

I normally send emails using CDO (ASP Classic) but the problem is, what happens when I need to send to users A though Z, or more?

User D comes along, hits POST, and then I write the text to the database and start sending out emails--and he has to wait until they are sent.

Obviously, that is not the way to handle this. But I am totally clueless as to what to implement here. A third party? A component? Is there a way to have this run in the background? Ive done a lot of websites but have never had to do email like this.

Any direction would be REALLY appreciated.

bolt19
  • 1,963
  • 4
  • 32
  • 41
msith718
  • 41
  • 3
  • 8
  • You tagged this as ASP.NET but mention using components of ASP Classic. Is this ASP.NET, or purely [ASP Classic](https://en.wikipedia.org/wiki/Active_Server_Pages)? – mason Feb 15 '17 at 18:34
  • Upvoted to cancel the effect of the unnecessary downvote. :-) – Craig Feb 20 '17 at 23:31

2 Answers2

0

ASP Classic cannot perform parallel actions or "background actions" like you're asking about. You have to simulate it, make your e-mail sending faster, or execute the emailer function using a scheduled task.

To simulate:

  1. Perform all the database transactions (e.g. save User D's post to your database)

  2. On the next page User D sees, initiate a call to an ASP file using a JavaScript tag. The ASP file called should send the e-mails, e.g.

    <script type="text/javascript" async defer src="my_emailer.asp?postID=XXX"></script>
    

The reason you would use the script method is because it would be called asynchronously by the page User D is directed to after POSTing.

To speed up

Create and send only one e-mail, but BCC the other recipients.

To Run As a Scheduled Task

Follow the post here for tips: Make server automatic run asp-script every day

Community
  • 1
  • 1
Robert S
  • 496
  • 4
  • 14
  • [ASP Classic](https://en.wikipedia.org/wiki/Active_Server_Pages) refers to something else. Please do not refer to ASP Classic when you mean to refer to ASP.NET or ASP.NET Web Forms. – mason Feb 15 '17 at 18:27
  • I meant to refer to ASP Classic. From what I gathered, OP stated he has an ASP Classic script and needs an ASP Classic solution. – Robert S Feb 15 '17 at 18:31
  • Yes. I am using ASP Classic. Thank you. The only problem with the javascript solution is, what if user D doesnt go to another page. Im thinking a scheduler may be a better option in that case. There is an asp compent - ASPMail by Persists software that has message queing. I think that might be what I need--but not 100 percent sure yet. And would sending one email with the rest BCC be valid? Is there a limit to the number of BCC? And is it more likely to be seen as spam? I guess the spam issue is irrelevent as these would be signed up users and would have recieved at least 1 email in the past. – msith718 Feb 16 '17 at 15:41
  • Does User D's browser take him to a different page when he POSTs, or is his text POST'd asynchronously? – Robert S Feb 16 '17 at 16:04
  • It is posted asynchronously. – msith718 Feb 16 '17 at 19:57
  • although, when the asynchrouns call comes back there is a javascript handling it. I update a div to let the user know the action has been completed. I dont see whay I cant call a javascript function to kick off email at that point, right? Do I need to do anything to specifiy the email call would be asynchronous? Or is that the default? – msith718 Feb 16 '17 at 20:00
  • Yes, you could call another JavaScript function that kicks off the e-mails after the asynchronous call comes back. – Robert S Feb 16 '17 at 20:15
  • the only issue is if user D doesnt have javascript. In that case, the form will still submit but the emails wouldnt get sent. iguess its a small enough percentage that it would not be significant. Its only a notification. What about the CDSYS ability to send mail to a pickup directory. I cant find any good info on that. Is that meant for having the emails sent from a separate process in the background? – msith718 Feb 17 '17 at 00:26
  • Also, the javascript example above, what tells it to process asynchronously... or is that just the nature of javascript calls? – msith718 Feb 17 '17 at 00:27
  • Check out this page to discusses the differences between the SendUsing options: https://snook.ca/archives/active_server_pages/cdosys_the_diff – Robert S Feb 17 '17 at 16:35
  • The `defer` attribute causes the script to fire off after the document loads. The `async` attribute causes the asynchronous execution. I apologize, but as you may notice, I had to add the `async` to my answer. I thought I had done so right after I posted it, but apparently the edit didn't take. – Robert S Feb 17 '17 at 16:37
  • Thanks Robert Simpson, I appreciate it. It makes sense, but why would I need the defer? Is it necessary that the page load completely first? and I will check out the page you referenced. So, I guess this is THE way to do it if the site is written in classic ASP? – msith718 Feb 18 '17 at 17:38
  • I won't say it is the "de facto" way to do it, but it is a way. Glad I could help! I say use the `defer` so there is no reason for the browser to delay the loading of the follow-on page. – Robert S Feb 19 '17 at 18:32
0

I have a scheduled task on my classic ASP site that runs at the top of every hour and sends emails for various reasons. Works great.

I schedule a batch file to run on the schedule I want. The batch file has one line that looks like this:

"C:\path\XMLRequester.vbs" http://example.com/SendFollowUpEmails.asp

XMLRequester.vbs is a little script that requests the ASP script, causing it to execute:

' Simpler XML Requester

On Error Resume Next

dim shell
Set shell = CreateObject("WScript.Shell")
Dim objXML, strURL

' Request URL from 1st Command Line Argument.  This is
' a nice option so you can use the same file to
' schedule any number of differnet scripts just by
' changing the command line parameter.

strURL = WScript.Arguments(0)

Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", strURL, False
objXML.Send

if Err.Number <> 0 then
    shell.LogEvent 1, "Error " & Err.Number & " (" & Err.Description & ")"
end if

Set objXML = Nothing
Set shell = Nothing

SendFollowUpEmails.asp is just an ASP script that does whatever it is you need it to do. In my case it queries the database to find the customers it needs to send the emails to, then sends them. It has some reasonable timeout value but if it runs out of time before it finishes, it will just pick up where it left off the next time it runs.

Craig
  • 3,253
  • 5
  • 29
  • 43