Click here to Skip to main content
11,926,933 members (54,328 online)
Rate this:
Please Sign up or sign in to vote.
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 5-Mar-13 1:41am
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.
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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#[^][^]

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

Good luck,
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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:
DateTime inTime = (DateTime) reader["intime"];
DateTime outTime = (DateTime) reader["outtime"];
TimeSpan diff = inTime - outTime;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 5 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100