Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a table in my database namely EmpAttendance.

This table has some columns likely empid,c_Date,intime,outtime,status.

How can is send these details as an attachment via email for every half an hour(i have created a windows application in c#).

also how can i calculate difference between outtime AND INTIME.
Posted
Comments
choudhary.sumit 5-Mar-13 6:52am    
i can understand you like this:
1. You want a email program written in c#.
2. You also want a timer code.
3. You are failed to make me understood what is outtime and intime here.
elaborate.
Harsha24 5-Mar-13 7:01am    
Here I am developing an windows application which stores the intime and outtime of an employee using Employee Id. status is used to know whether employeee is IN or OUT.
I have done all this stuff.
Now i need to send an email which carries the details where status is equal to IN. and this process should be done for evrey 30 min.

Also i need to calculate the differene between Outtime and intime that is total working hours.

Your best option for this is to use a windows scheduler or using a windows service.
Example links for Win Scheduler:
Link 1[^]
Link 2[^]
How to create a Win Service:
Creating a Basic Windows Service in C#[^]
http://tech.pro/tutorial/895/creating-a-simple-windows-service-in-csharp[^]

Sending email with attachments:
MSDN MailMessage.Attachment property[^]
Example code[^]

Good luck,
OI
 
Share this answer
 
Set up a timer, probably one minute intervals is fine, then have a counter which gives you the half hour. In the timer Tick event handler deal with the counter, and when it expires read the data from the DB.

Format the data into HTML and send it as an HTML email: Sending an Email in C# with or without attachments: generic routine.[^] should help.

Time differences are also easy:
C#
DateTime inTime = (DateTime) reader["intime"];
DateTime outTime = (DateTime) reader["outtime"];
TimeSpan diff = inTime - outTime;
 
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