• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

Using scheduled exe to send email on server

Hi everybody,

I have an asp page which loops thru my database and sends out emails. I need this to be scheduled everyday.
Unfortunately this will not be hosted on my server and so are limited in regards to installing components or updates. Fortunately they are using windows 2003 server so I should have a few more options - right?

Anyway the crux is this. They don't want to schedule anything but an exe. Originally I told them to schedule a direct call with IE to the asp page using just the built in windows scheduled tasks but they weren't happy with that, then I supplied to them a vbs file which calls a bat file as explained in "4guysfromrolla.com" and "asp101.com" but they had issues with the XMLHTTP object.

So my question is how would get this into an exe. Would it be possible not to have a separate asp page and have all the code, or similar, within said asp page in the exe? Is it hard to write exe like this and could I do this with just a text editor. If I could get some examples or tutes, that would be great. This has been going on for a while now and would love to just give them what they want and be done with it

We are using MS SQL as the db and I think a SQL agent job could be out too :)

They will still schedule the exe using the windows scheduled tasks

Many thanks in advance!
2 Solutions
Saqib KhanSenior DeveloperCommented:
First of all, why are you using xmlhttp in VBS file. you Grabbing Content of some website?

Creating EXE is very simple if you have Visual Basic. Paste your Code into a VB form, with slight changes into your Code you can compile a EXE file.
8aceAuthor Commented:
Hey, i was just following a tute :) The XMLObject seems to do the call to the ASP page on the server.
I was scared that I would need Visual Basic as I dont - any other ideas?

If they just had problems with the xml http object I would still use a vbscript file (if you don't have access to vb6 or .net).  I would use the CDO library to send mail, there is plenty of information out there on CDO and it is pretty straightforward & easy to use.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

8aceAuthor Commented:
Would it be simplier if i did this vb6 - if it came to it I could get my hands on a copy. However, my skills in this department are pretty limited. ASP code i know (well enough to get by) - creating exes and vb i don't. I have spent a lot of time giving them everything but exe - i just want to give them what they want and wash my hands :)

Basically the site in one big outlook calendar type thing. It stores events and display them like a calendar. Users can subscribe to these events and recieve an email 2 days and 2 weeks before the event. This is the smallest part of the site and it seems to be causing the most headaches.

The asp works like this

Get the current date and and add 2 days (or 2 weeks) to it and save as variable.

Loop thru the database and get all Events from the event table which will happen on that day
Work out the type of subscriber to the event, get their details from another table and send them an email using CDOSYS.

What i want is something that v.easy for him to set up (pref one file) and gets me back into the good books. If it means rewriting the asp code then so be it, as long as i can keep the steps above.


If you are going to integreate inside your site and you dont have much exposure on VB you can just do the above steps as an function and save it as .inc file. add that function to your startup page so that it will get executed asa some users access the site, also you can add a field on some table and update the field with current date so that you can recheck it on next day to send mails again, say if current date is on table then you can just ignore calling the function or you can call the function to send mail. If you feel that you have more data to get transfered then you can add an iframe with width of 0 px and height of 0px on your site and call the asp page inside the iframe.


You can create an exe in C++, which would be the simplest of its kind. It will just use a system function the argument to which you can pass any DOS command. And the moment you run the C++ file it will create the exe file. In the DOS command you can send a cscript command which will execute your vbs file. And once in the vbs you can do anything you want, be it sending the mail or accessing the database.
This way you will be saved from using VB also.

Mohit Raj
Could you set up a scheduled task on your client workstation that would invoke an instance of IE pointing to a specially crafted ASP file on the server that would do all the queries and processing and then close automatically when complete.  No .EXE file would be needed and the server people need never know....
@ danataylor

I dont think so if it would be possible to setup a schedule task on the clients and neither I think it is a good practice. If the clients are limited and known machines then it might be a work around but even then it will have to be done manually otherwise if the script is required to do this then also DOS command (at command) needs to be executed which squares on to the same problem rather than the solution.

Using client machine functionalities also will limit the usage of application and defeats the purpose of intranet/internet application. This will also result in high user intrusivness level.

Mohit Raj
use VBS. You dont have to Call ASP file using xmlhttp object.
You can write Same ASP code within VBS file and Execute it.

only difference would be instead of Server.CreateObject use CreateObject in VBS.

give it a try, I have developed some schedule Taks using VBS, which Connects to SQL loops through the Records and Email Consumers.
8aceAuthor Commented:
@ danataylor
Love it - very sneaky but no can do

gonna split the points between Khansoul and mohitraj - thanks guys

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now