Declarations
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
str Body,CCEmail;
// Get Email forthe employee
select HcmWorker where HcmWorker.PersonnelNumber == HcmEmploymentLeave.PersonnelNumber;
select DirPartyTable where DirPartyTable.RecId == HcmWorker.Person;
select DirPartyLocation where DirPartyLocation.Party == DirPartyTable.RecId;
select LogisticsElectronicAddress where LogisticsElectronicAddress.Location == DirPartyLocation.Location
&& LogisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email;
// To get email for Dept heads
DeptHead = HcmWorker::findRecId(HcmWorker.DepartmentHead).Person;
select DirPartyTableDeptHead where DirPartyTableDeptHead.RecId == DeptHead;
select DirPartyLocationDeptHead where DirPartyLocationDeptHead.Party == DirPartyTableDeptHead.RecId;
select LogisticsElectronicAddressDeptHead where LogisticsElectronicAddressDeptHead.Location == DirPartyLocationDeptHead.Location
&& LogisticsElectronicAddressDeptHead.Type == LogisticsElectronicAddressMethodType::Email;
// To get email for TeamLead
TeamLead = HcmWorker::findRecId(HcmWorker.Supervisor).Person;
select DirPartyTableTeamLead where DirPartyTableTeamLead.RecId == TeamLead;
select DirPartyLocationTeamLead where DirPartyLocationTeamLead.Party == DirPartyTableTeamLead.RecId;
select LogisticsElectronicAddressTeamLead where LogisticsElectronicAddressTeamLead.Location == DirPartyLocationTeamLead.Location
&& LogisticsElectronicAddressTeamLead.Type == LogisticsElectronicAddressMethodType::Email;
//For SMTP
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
if(HcmEmploymentLeave.LeaveTypes == HcmAbsenceType::PermissionLeave)
{
CCEmail = LogisticsElectronicAddressDeptHead.Locator +";"+LogisticsElectronicAddressTeamLead.Locator;
mailer.fromAddress(
'hr@dynamicnetsoft.com');
mailer.tos().appendAddress(LogisticsElectronicAddress.Locator);
mailer.ccs().appendAddress(CCEmail);
mailer.htmlBody("Dear <b>"+ HcmEmploymentLeave.Employeename()+ "</b>,<br/><br/>We have processed your Permission Request referenced "+ HcmEmploymentLeave.AbsenceID+ " dated "+ date2StrUsr(HcmEmploymentLeave.PostingDate)+ " for the date "+ date2StrUsr(HcmEmploymentLeave.StartDate)+ " from "+ time2str(HcmEmploymentLeave.StartTime, TimeSeparator::Colon, TimeFormat::AMPM)+" to "+ time2str(HcmEmploymentLeave.EndTime,TimeSeparator::Colon, TimeFormat::AMPM)+ " for "+ time2StrHMS(HcmEmploymentLeave.NoOfHours)+ " hours. "+ "<br/><br/>Leave ID:"+ HcmEmploymentLeave.AbsenceID+ "<br/>Leave Type:"+ enum2str(HcmEmploymentLeave.LeaveTypes)+ "<br/>Start Date:"+ date2StrUsr(HcmEmploymentLeave.StartDate)+ "<br/>End Date:"+ date2StrUsr(HcmEmploymentLeave.EndDate)+ "<br/>Start Time:"+ time2str(HcmEmploymentLeave.StartTime, TimeSeparator::Colon, TimeFormat::AMPM)+ "<br/>End Time:"+ time2str(HcmEmploymentLeave.EndTime, TimeSeparator::Colon, TimeFormat::AMPM)+ "<br/>No.of Hours:"+ time2StrHMS(HcmEmploymentLeave.NoOfHours)+ "<br/>Reporting to Office on:"+ date2StrUsr(HcmEmploymentLeave.ReportingOn)+ "@"+ time2str(HcmEmploymentLeave.ExpectedTime, TimeSeparator::Colon, TimeFormat::AMPM)+ "<br/>No. of Permission taken in this month:"+ int2str(HcmEmploymentLeave.PermissionCount)+ "<br/>Note: Only 3 Permission is allowed per month, any additional permission will be considered as LOP or deduction in your vacation Holidays."+ "<br/><br/>Please submit or update HR on your report to work with in 1 hour from your reporting time. Failure to do so may result in deduction of Half Day from your vacation days."+ "<br/><br/><br/>***<b>This is a system generated email, so please do not reply to this mail. For any clarifications in your leave request, please contact HR directly </b>***");
mailer.subject("HR Alert: Your Permission Request ID "+ HcmEmploymentLeave.AbsenceID+ " dated "+ date2StrUsr(HcmEmploymentLeave.PostingDate));
mailer.sendMail();
}
else
{
CCEmail = LogisticsElectronicAddressDeptHead.Locator +";"+LogisticsElectronicAddressTeamLead.Locator;
mailer.fromAddress(
'hr@dynamicnetsoft.com');
mailer.tos().appendAddress(LogisticsElectronicAddress.Locator);
mailer.ccs().appendAddress(CCEmail);
mailer.htmlBody("Dear <b>"+ HcmEmploymentLeave.Employeename()+"</b>,<br/><br/>Thank you for submitting your leave application form.<br/><br/>We have processed your leave application referenced "+ HcmEmploymentLeave.AbsenceID+ " dated "+ date2StrUsr(HcmEmploymentLeave.PostingDate)+ " against "+ enum2str(HcmEmploymentLeave.LeaveTypes)+ " for the date starting from "+ date2StrUsr(HcmEmploymentLeave.StartDate)+" to "+ date2StrUsr(HcmEmploymentLeave.EndDate)+ " for "+ int2str(HcmEmploymentLeave.NoOfDays)+ " day/days. "+ "<br/><br/>Leave ID:"+ HcmEmploymentLeave.AbsenceID+ "<br/>Leave Type:"+ enum2str(HcmEmploymentLeave.LeaveTypes)+ "<br/>Start Date:"+ date2StrUsr(HcmEmploymentLeave.StartDate)+ "<br/>End Date:"+ date2StrUsr(HcmEmploymentLeave.EndDate)+ "<br/>No.of Days:"+ int2str(HcmEmploymentLeave.NoOfDays)+ "<br/>Report back to Work: "+ date2StrUsr(HcmEmploymentLeave.ReportingOn)+ "<br/><br/>The application has been processed in the system successfully and intimated to your higher authority by email. So please complete your “Report Back to Work” procedure on your return to work day "+ (date2StrUsr(HcmEmploymentLeave.ReportingOn))+ " and submit it to HR without fail to update the system off your return."+ "<br/><br/>As per the current records, following are the available leaves for your reference."+ "<br/><br/><br/>Casual Leave:"+ num2str(HcmEmploymentLeave.NoOfCasualDaysAvailable,1,2,1,2)+ "<br/>Privilege Leave:"+ num2str(HcmEmploymentLeave.NoOfPrivilegedLeaveAvailable,1,2,1,2)+ "<br/>Sick Leave:"+ num2str(HcmEmploymentLeave.NoOfSickLeaveAvailable,1,2,1,2)+ "<br/>Records as of "+ date2StrUsr(HcmEmploymentLeave.PostingDate)+ "<br/><br/>Please submit your “Report Back to Work form” duly signed by immediate reporting authority before end of "+ date2StrUsr(HcmEmploymentLeave.ReportingOn)+ "."+ " <br/>Note: For Sick leave, it is mandatory you need to submit your Medical Certificate."+ "<br/><br/><br/>***<b>This is a system generated email, so please do not reply to this mail. For any clarifications in your leave request, please contact HR directly </b>***");
mailer.subject("HR Alert: Your Leave Application "+ HcmEmploymentLeave.AbsenceID+ " dated "+ date2StrUsr(HcmEmploymentLeave.PostingDate));
mailer.sendMail();
}