public bool RecallLeave(string pkleaveInfoID, string employeeID) { Log.Info(GlobalParams.StartRecallLeave); bool result = false; try { EmailConfig.SetRootPath(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath); LeaveInfo leaveInfo = LeaveBLL.GetLeaveInfoByID(pkleaveInfoID); result = LeaveBLL.RecallLeave(pkleaveInfoID); Employee employee = EmployeeBLL.GetEmployeeByID(employeeID); if (result && EmailConfig.EmailTemplates.ContainsKey(EmailType.ApplyLeave.ToString())) { Log.Info(GlobalParams.StartMail); EmailContent ec = EmailConfig.EmailTemplates[EmailType.RecallLeave.ToString()]; // {0} - Manager First Name // {1} - First Name // {2} - Hours // {3} - Leave Type // {4} - Reason // {5} - Description // {6} - Start // {7} - End // {8} - CARSAddress string emailBody = string.Format(ec.Body, employee.Manager.FirstName, employee.FirstName, leaveInfo.Hours, leaveInfo.Type.Name + " Leave", leaveInfo.Reason, leaveInfo.Description, leaveInfo.FirstStartTime.ToString(EmailConfig.TimeFormatInEmail), leaveInfo.LastEndTime.ToString(EmailConfig.TimeFormatInEmail), EmailConfig.CARSAddress); // {0} - First Name // {1} - Hours // {2} - Leave Type string emailTitle = string.Format(ec.Title, employee.FirstName, leaveInfo.Hours, leaveInfo.Type.Name + " Leave"); string employeeEmail = GetEmail(employee.Email); string managerEmail = GetEmail(employee.Manager.Email); List <string> ccList = new List <string>(); ccList.Add(employeeEmail); #if DEBUG managerEmail = "*****@*****.**"; #endif SendMail sender = new SendMail(managerEmail, ccList, EmailConfig.EmailAccount, emailBody, emailTitle, EmailConfig.Password, EmailConfig.Host); sender.Send(); Log.Info(GlobalParams.EndMail); } else { Log.Warn(GlobalParams.MailError); throw new Exception(GlobalParams.MailError); } } catch (Exception ex) { Log.Exception(ex.StackTrace); Log.Exception(ex.Message); throw ex; } Log.Info(GlobalParams.EndRecallLeave); return(result); }