hi,
pls tell me....
how to generate a msg as a reminder for our important dates like "upcoming birthday"
thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Aug 18, 2009, 11:17 AM
Here i have Coded what you needed after lot of thinking ...
dont Forget to mark "Do you like answer" it will give me some Credit :)
----------------------------------------------------------------------------------------------------------------------
+ Application Will Store all the reminder in Database and Will Show Note About Upcoming reminder On Screen
+ It Will Check For New reminders Every 1 Hour and Send mail About Upcoming Reminders to User
+ to Keep Alerting User You have to Start Application When Computer Start so that Application Will Send Mail on Regular Intervals
+ I have included Project File Take A Look at That So you can get Better Idea See Link at bottom:)
---------------------------------------------------------------------------------------------------
private void Form1_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand comm = new SqlCommand("select * from Reminder",con);
SqlDataAdapter da = new SqlDataAdapter(comm);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
CheckEvents();
}
//Check For new Events and Send mail To User About reminders At Every 1 hour
private void timer1_Tick(object sender, EventArgs e)
{
CheckEvents();
SendMail();
}
public void CheckEvents()
{
foreach (DataGridViewRow r in dataGridView1.Rows)
{
if (dataGridView1.Rows.Count > 0)
{
DateTime DateToCompare = DateTime.Parse(r.Cells[2].Value.ToString());
DateTime TodayDate = DateTime.Now;
TimeSpan t = DateToCompare.Subtract(TodayDate);
string DateOfReminder = r.Cells[2].Value.ToString();
string ReminderNote = r.Cells[1].Value.ToString();
int DaysLeft = t.Days;
if (t.Days <= 10)
{
string FinalString = DateOfReminder + "==>" + ReminderNote + "==>Days left " + DaysLeft;
richTextBox1.Text += FinalString + "\n";
}
}
}
}
//Sending Mail About Reminder to User
public void SendMail()
{
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 786);
smtp.Credentials = new NetworkCredential("username", "password");
smtp.EnableSsl = true;
MailMessage msg = new MailMessage(new MailAddress("[email protected]"), new MailAddress("[email protected]"));
msg.Subject = "Private Reminder";
msg.Body = richTextBox1.Text;
smtp.Send(msg);
}
urmila kandariPosted Aug 24, 2009, 1:29 AM
thanks for help........
urmila kandariPosted Aug 18, 2009, 1:11 AM
i just want like we' ve form where we'll fill all the important dates like our insurance date, some impt meeting dates ect. nd before ten days automaticaly it start to generat messages on our valid email -id that ur meeting on that date (same we had fill on form )
i means it work like our moblie reminder
thanks
Kirtan PatelPosted Aug 17, 2009, 6:41 AM
can you Provide me some more detailes what exactly you want to achieve as final result
Explain your scenario a lil bit more so can take a look at your problem batter :)