You can't achieve this through an asp.net application
you will need to use a windows service.
create a windows service which runs at intervals of 5 mins. put code in the windows service which checks the system time and when it goest past 12:00 pm, it sends out emails.
Dont forget to mark as answer if this post helped you.
--------------------------
No Fate but what we make.
Based on my understanding, you want to send mail message with specific time. Such as e-mail users once a month, or on their birthday, or to send you details every day about what went on in the database that day.
Windows service is a good choice. Besides, you can achieve it by using SQLSever. The below link which can help you out.
You can trigger the function of sending message mail in a month. Before sending, you can check his targets in this trigger. If he hasn't achieved it, you can send mail.
You can start a thread which handles sending the emails. The thread can be started when the application starts. Use Application_Start function in Global.asax to do so. Here is what your code will look like .. its not tested but will give you a fair idea
of what I am talking about.
public System.Threading.Thread emailSender = null;
protected void Application_Start(object sender, EventArgs e)
{
emailSender = new System.Threading.Thread(
new System.Threading.ThreadStart(RunEmailSender));
emailSender.Start();
}
private void RunEmailSender()
{
// Always keep running.
while (true)
{
System.Threading.Thread.Sleep(60000);
try
{
SendEmails();
}
catch (Exception ex)
{
// Log any exceptions here
}
}
}
Your solution works well when you can use SQL Server ofcourse. I offered a pure .Net solution. Not only sending emails, threading solution can be used to implement other behind the scene processes like cleaning cache, dealing with filesystem etc.
Thanks for the SQL Server emailing solution though.
Your solution works well when you can use SQL Server ofcourse. I offered a pure .Net solution. Not only sending emails, threading solution can be used to implement other behind the scene processes like cleaning cache, dealing with filesystem etc.
Thanks for the SQL Server emailing solution though.
Regards
Tajinder Sarao
First of all your solution is really bad idea since it will affect website's performance Scheduling should never done on a website it should either be done through windows service or using SQL Job schedular and in that too SQL Server job schedular is the
best since shared hosting does not allow windows services. Pure .Net solution ? What that means MS SQL server Job Schedular handles quite cleanly against the solution you have provided
suryabeniwal
Member
45 Points
32 Posts
HOw i can send mail at 12:00 pm of every day in asp.net application ?
May 26, 2009 02:44 AM|LINK
Hi, i wants to send mail to admin of the website at 12 pm of every day automatically anybody plase help me .
how is this possible get time of server and post the mail everyday ?
please reply me
at midnight email mail server time asp.net c#
atiface
Member
424 Points
71 Posts
Re: HOw i can send mail at 12:00 pm of every day in asp.net application ?
May 26, 2009 03:49 AM|LINK
You can't achieve this through an asp.net application
you will need to use a windows service.
create a windows service which runs at intervals of 5 mins. put code in the windows service which checks the system time and when it goest past 12:00 pm, it sends out emails.
--------------------------
No Fate but what we make.
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: HOw i can send mail at 12:00 pm of every day in asp.net application ?
May 27, 2009 03:13 AM|LINK
Based on my understanding, you want to send mail message with specific time. Such as e-mail users once a month, or on their birthday, or to send you details every day about what went on in the database that day.
Windows service is a good choice. Besides, you can achieve it by using SQLSever. The below link which can help you out.
http://classicasp.aspfaq.com/email/how-do-i-send-e-mail-from-sql-server.html
You can trigger the function of sending message mail in a month. Before sending, you can check his targets in this trigger. If he hasn't achieved it, you can send mail.
This thread can help you. http://forums.asp.net/t/1202964.aspx
The following links also will help you ...
http://aspalliance.com/1087_Working_with_Windows_Services_in_NET.all
http://www.developerfusion.co.uk/show/3441/2/
http://montgomerysoftware.com/CreatingWindowsServiceInCSharp.aspx
http://note2.industriousone.com/writing-windows-services-c
http://www.dotnetclassic.com/post/Send-Email-With-AspNet.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
tssarao
Member
8 Points
4 Posts
Re: HOw i can send mail at 12:00 pm of every day in asp.net application ?
May 29, 2009 06:20 PM|LINK
You can start a thread which handles sending the emails. The thread can be started when the application starts. Use Application_Start function in Global.asax to do so. Here is what your code will look like .. its not tested but will give you a fair idea of what I am talking about.
public System.Threading.Thread emailSender = null;
protected void Application_Start(object sender, EventArgs e)
{
emailSender = new System.Threading.Thread(
new System.Threading.ThreadStart(RunEmailSender));
emailSender.Start();
}
private void RunEmailSender()
{
// Always keep running.
while (true)
{
System.Threading.Thread.Sleep(60000);
try
{
SendEmails();
}
catch (Exception ex)
{
// Log any exceptions here
}
}
}
private void SendEmails()
{
}
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: HOw i can send mail at 12:00 pm of every day in asp.net application ?
May 29, 2009 06:30 PM|LINK
Refer my article
http://www.aspsnippets.com/post/2009/03/08/Automated-Email-Notifications-using-SQL-Server-Job-Schedular.aspx
I have explained an easy way to achieve it using job schedular
Contact me
tssarao
Member
8 Points
4 Posts
Re: HOw i can send mail at 12:00 pm of every day in asp.net application ?
May 29, 2009 06:36 PM|LINK
Your solution works well when you can use SQL Server ofcourse. I offered a pure .Net solution. Not only sending emails, threading solution can be used to implement other behind the scene processes like cleaning cache, dealing with filesystem etc.
Thanks for the SQL Server emailing solution though.
Regards
Tajinder Sarao
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: HOw i can send mail at 12:00 pm of every day in asp.net application ?
May 29, 2009 06:50 PM|LINK
First of all your solution is really bad idea since it will affect website's performance Scheduling should never done on a website it should either be done through windows service or using SQL Job schedular and in that too SQL Server job schedular is the best since shared hosting does not allow windows services. Pure .Net solution ? What that means MS SQL server Job Schedular handles quite cleanly against the solution you have provided
Contact me
tssarao
Member
8 Points
4 Posts
Re: HOw i can send mail at 12:00 pm of every day in asp.net application ?
May 29, 2009 07:49 PM|LINK
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: HOw i can send mail at 12:00 pm of every day in asp.net application ?
Jun 01, 2009 03:13 AM|LINK
Can you tell me, whether provided links are helpful to you
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
suryabeniwal
Member
45 Points
32 Posts
Re: HOw i can send mail at 12:00 pm of every day in asp.net application ?
Jun 01, 2009 04:32 AM|LINK
Thanks everybody for help me
i have done this task by using batch file and set the scheduler u can sent mail any time which u set in the scheduler ..............