-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSendMail.php
74 lines (65 loc) · 2.21 KB
/
SendMail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
$serverName = "localhost";
$connectionInfo = array("Database"=>"ZKTeco_AC_DB", "UID"=>"sa", "PWD"=>"P@55w0rd");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn === false ) {
echo "Connection could not be established.<br />";
die (print_r(sqlsrv_errors(), true));
}
$sql = "SELECT A1.USERID, A2.NAME, A2.BADGENUMBER,CONVERT(char(19),A1.CHECKTIME,120) 'CHECKTIME'
FROM CHECKINOUT A1,USERINFO A2
WHERE (
DATEPART(yy,A1.checktime)=datepart(yy,convert(char(10),GETDATE(),120)) and
DATEPART(mm,A1.checktime)=datepart(mm,convert(char(10),GETDATE(),120)) and
DATEPART(dd,A1.checktime)=datepart(DD,convert(char(10),GETDATE(),120)) and
DATEPART(HH,A1.checktime) between 07 and 08
) and A1.USERID = A2.USERID
order by A1.CHECKTIME";
$stmt = sqlsrv_query($conn, $sql);
if (!$stmt){
die(print_r(sqlsrv_errors(),true));
}
?>
<?php
$MyBody="<html><head></head><body>";
$MyBody.='<table rules="all" style="border-color: #666;" cellpadding="10">';
$MyBody.= "<tr style='background: #eee;'>";
$MyBody.= "<td><strong><b>Employee ID</b></td>";
$MyBody.= "<td><strong><b>Employee NAME</b></td>";
$MyBody.= "<td><strong><b>Clock In</b></td></tr>";
$MyBody.= "<tr>";
while ($row = sqlsrv_fetch_array($stmt)){
$MyBody.= "<td><strong>".$row['BADGENUMBER'] ."</td>";
$MyBody.= "<td><strong>".$row['NAME'] ."</td>";
$MyBody.= "<td><strong>".$row['CHECKTIME'] ."</td>";
$MyBody.= "</tr>";
}
$MyBody.="</table></body></html>";
sqlsrv_free_stmt($stmt);
?>
<?php
$filename = 'C:\inetpub\wwwroot\PHPMailer\PHPMailerAutoload.php';
if(file_exists ( $filename ) ){
//require ('C:\inetpub\wwwroot\PHPMailer\class.phpmailer.php');
require ('C:\inetpub\wwwroot\PHPMailer\PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->SMTPAuth=false;
$mail->Username="sc.skycallzmis";
$mail->Password="tj;4jo6jp6cj84";
$mail->From="skycallzmis@skycallz.com";
$mail->FromName="Skycallz IT";
$mail->AddAddress("dennis.su@skycallz.com","Dennis Su");
$mail->WordWrap=50;
$mail->Subject="Clock In/Out Notice Mail";
$mail->Body=$MyBody;
$mail->IsHTML(true);
if(!$mail->Send()){
echo "Sending Email Error: ". $mail->ErrorInfo;
}else{
echo "Email Sending Successful!";
}
}else{
echo "The Files does not exist.";
}
?>