Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have an asp.net application where I have added a timer control with interval of 1000ms. I am facing three types of problems:

1) The page, when viewed in browser, is loading itself every second, with the interval of timer.
I do not want this as the application is going to be quite heavy and if final application keeps re-loading it like this, it will be a total failure.

2) The purpose of the timer is to check the time and date every second, when the right time approaches, it should send an email. This function is not working. I am using below code.
VB
If DateTime.Now = DateTime.Parse("01.13.2014 20:34") Then
            Call SendEmail()
            Timer1.Enabled = False
        End If


3) I want to set this time using DateTimePicker like control, that we use for Winforms. Is anything like that possible? When hosted on server, where shall the time be taken, as on local server, it is taking from my system.

Thanks
Posted
Comments
I guess you have rejected my answer by mistake after accepting it.
In that case, please accept and up-vote.

Thanks,
Tadit

For sending mails, you can create Console Application and add that to the Windows Task Scheduler.
You can select the Date and Time when to start and also set the repetition frequency.

It would automatically trigger, when the time interval is reached and repeat itself.
 
Share this answer
 
Comments
Furqan Sehgal 15-Jan-14 1:52am    
Can be added to Task Scheduler. It is an asp.net application, to be hosted on server.
No, as I said create one Console App. You can add one executable file (.exe) to the Task Scheduler.
Furqan Sehgal 18-Jan-14 10:53am    
Task scheduler of my computer or server?
If you mean server, will the host allow me to change settings of his computer? I already asked and the answer is no.
If you can't add one Sceduler on the Server, then I guess there is no other way out.
You can also take a look at Schedule Email Through ASP.NET or Schedule Tasks Using ASP.NET and Schedule your web tasks with the WebTaskScheduler. But I am not sure.
Furqan Sehgal 21-Jan-14 5:11am    
Dear Tadit ! Thanks a lot. Your suggestion showed me the way how to do it.
I have explained the process below in my answer. it is working great even though browser is closed.
Once again, Thanks
I have just discovered that we only need to add Global.asax file (right click project in server explorer and Add New Item>> Add Global Application)

Just put your email code in the file. When hosted, it runs through IIS, even though browser is closed.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900