Click here to Skip to main content
14,491,551 members
Rate this:
Please Sign up or sign in to vote.
See more: , +
Hi friends,

In my application I am required to make a Cron to send emails to my users.
For this I am using the following code. But In task scheduler it gets marked as "Task Completed" and do not receive the email, though it works when I hit "Email.aspx" from
"http://localhost:51611/Cron/Email.aspx"
and the necessary flags get updated in the database.

I am using
1. CronMail.js - A java script that hit the Email.aspx page.
2. Email.aspx -- this is the page that process the email task.

CronMail.js
var strUrl = new Array("http://localhost:51611/Cron/Email.aspx");
var webObj = WScript.CreateObject("MSXML2.ServerXMLHTTP");

var lResolve = 10 * 1000;
var lConnect = 10 * 1000;
var lSend = 60000 * 1000;
var lReceived = 60000 * 1000;

webObj.setTimeout(lResolve, lConnect, lSend, lReceived);

for (var i = 0; i < strUrl.length; i++) {
    webObj.open("GET", strUrl[i], false);
    try {
        webObj.send();
        if (webObj.status != 200 || String(webObj.statusText).match(/Database is currently unavailable/gi) != null) {

        }
    }
    catch (e) {
    }
}


But when I configured this with task scheduler, using
"cscript.exe"
is not working and neither the values got updated in database nor email were being sent. The same configuration is done with other application that are working.


Please guide me.
Posted
Comments
CdnSecurityEngineer 27-Jan-14 13:31pm
   
What browsers are you using, does it work in one browser and not an another.
Manish Kumar Namdev 28-Jan-14 0:16am
   
Hi, I didn't check it because it is run by task scheduler at server.
Is there any other way to use cron?
CdnSecurityEngineer 28-Jan-14 10:53am
   
Well what debugging have you done? do you have any idea/where how this is failing? I am suspecting that if your call to WScript.CreateObject("MSXML2.ServerXMLHTTP"); if this call is failing, you're going to throw an error before you enter your try.

The other odd thing, is where is localhost resolving too? A browser would resolve that to the local user's computer. Are you sure your user is creating data in the database when they hit this page?

IS port 51611 open on your server?

When you test this are you testing from the server? OR from a client separate and away from the server?

It also seems weird that you're using the GET method to send data back to the server, a WebMethod and a POST, or a Webservice (POST) WebAPI, depending on which version of ASP.NET you're using would be more logical.
Manish Kumar Namdev 31-Jan-14 3:35am
   
I am using at my local not on server. Therefore I used localhost for testing purpose

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100