Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

This is regarding the checking the Date. In my application, i have date field where it will set to 2nd june, 2016 (as a deadline).
What i have to get now is, tomorrow, i should get an email (i have the email code) based on the Date field.

How can i check this? any help is appreciated.

What I have tried:

I tried Date.Now but it is not working. I think i went wrong somewhere.
Posted
Updated 31-May-16 23:43pm
Comments
Suvendu Shekhar Giri 1-Jun-16 5:35am    
Use `System.DateTime.Now` to get current datetime.
It would be great if you can share the code you have tried so far so that we can suggest an appropriate solution to your problem.

1 solution

If you have a dead line to check then it's simple:
C#
DateTime deadLine = new DateTime(2016, 6, 2);
...
if (DateTime.Now >= deadLine && emailNotSentYet)
   {
   // Send your email.
   emailNotYetSent = false;
   ...
   }

But just writing that code won't automatically send the email. First, your app has to be running at the time, and you would need to check repeatedly in order to catch the time, possibly with a Timer control.

What I would do is to create a small app that had no UI, but that just read the deadline from a file or a database, and checked it against the current date. If it should, it sends the email and kills the deadline in the file. Either way it then exits.
I'd then arrange for the Windows Scheduler to run that every half hour or so.

Make sense?
 
Share this answer
 

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