Last post Oct 18, 2008 11:32 AM by Nemesis116
Oct 17, 2008 06:12 AM|shweta.parikh|LINK
in my system i have created one control of reminder,
now what i want to do is the system will automatically throw email to users of today's reminder.
i mean if u set the reminder of today then u will get the email.
i dont know how do i set this.
i have never worked on this before.
so i m confused.
can anyone help me?
Oct 17, 2008 08:10 AM|anonymouswrites|LINK
Create an isntance of timer object in gobal.asax
Start the timer in application start event
set the email sending function to send emails once every day
some thing like this
public class EmailTimer
private Timer timer ;
timer = new Timer
Interval = TimeSpan.FromDays(1).TotalMilliseconds,
Enabled = false
timer.Elapsed += SendEmails;
private void SendEmails(object sender, ElapsedEventArgs e)
// write the code to send emails here.
public void start ()
protected void Application_Start(object sender, EventArgs e)
EmailTimer etimer = new EmailTimer();
Oct 17, 2008 08:32 AM|Nemesis116|LINK
I don't know if this is a clean solution..
I would rather make this happen at database level. Ads/cons?
Oct 17, 2008 09:05 AM|shweta.parikh|LINK
thanks for your reply but can u send me the complete code.
i mean my reminder details wil cm from db.
so how do i set there?
sorry but i dont have any idea about global.asax
so i m asking u.
can u send me specific code for that?
Oct 17, 2008 09:38 AM|shazzmerc1|LINK
Iam going to explain you what is Global.asax file
The Global.asax file (also known as the ASP.NET application file) is an optional file that is located in the application's root directory and is the ASP.NET counterpart of the Global.asa of ASP. This file exposes the application and session level events
in ASP.NET and provides a gateway to all the application and the session level events in ASP.NET. This file can be used to implement the important application and session level events such as Application_Start, Application_End, Session_Start, Session_End,
etc. This article provides an overview of the Global.asax file, the events stored in this file and how we can perform application wide tasks with the help of this file.
Oct 18, 2008 09:44 AM|anonymouswrites|LINK
To add a global.asax file in your project, add new item and from the list of items select global.asax file.
It will automatically add application start event.
Create a new class called as EmailTimer and instantiate the object in application start.
Oct 18, 2008 09:49 AM|shweta.parikh|LINK
first of all thanks for the reply.
but my confusion is how do i get my data from db in class?
Oct 18, 2008 10:14 AM|anonymouswrites|LINK
You can use the following code to get the data from database
SqlConnection conn =" Connectionstring";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
string strQuery = "Select * FROM TableName
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
SqlDataReader reader = cmd.ExecuteReader();
// read the data here
Oct 18, 2008 11:20 AM|manpreetsingh.MCA|LINK
If u wanna send auto-email, I think thr are two best alternatives i.e..
either u should use the windows service or u can do this at Database End using
"Jobs" or u may also use windows script for the purpose...
for more details u may find it very easily using google...
Oct 18, 2008 11:23 AM|shweta.parikh|LINK
k i wil try
Oct 18, 2008 11:32 AM|Nemesis116|LINK
I'd prefer using a job for this at database level.
Create a stored procedure which runs through all the reminders and sends a database mail.