Sent mail template HTML AX 2012
Nghia Song - Microsoft Dynamics 365 Technical Consultant
Nghia Song
Tel - WhatsApp: +84967324794
Email: songnghia.uit@gmail.com
Nghia Song
Tel - WhatsApp: +84967324794
Email: songnghia.uit@gmail.com
private void sendMail()
{
SysEmailRecipients recipientEmail;
HcmWorker hcmWorker = HcmWorker::find(worker);
HcmWorker hcmWorkerMan;
Email workerManEmail;
Name wokerName;
Map mappings;
int i;
VhpOTRegistrationTable regTable = VhpOTRegistrationTable::find(regNo);
str regLine;
container listWorker = VhpAbsenceWorkerApproval::getManagerApprovalByWoker(worker);
VhpAbsenceWorkerApproval absenceWorkerApproval;
;
if(regTable.status == VhpOTRegistrationTableStatus::confirmed || regTable.status == VhpOTRegistrationTableStatus::approved)
{
//Get recipient Email manage
for(i = 1; i <= conLen(listWorker); i++)
{
hcmWorkerMan = HcmWorker::find(conPeek(listWorker, i));
absenceWorkerApproval = VhpAbsenceWorkerApproval::find(hcmWorkerMan.RecId, HcmEmploymentAbsenceSetup::findByEmployment(HcmEmployment::findByWorkerLegalEntity(worker, CompanyInfo::current()).RecId).AbsenceSetupId);
if(absenceWorkerApproval.SendMail)
{
workerManEmail = hcmWorkerMan.email();
if(workerManEmail)
{
if(!recipientEmail)
{
recipientEmail = workerManEmail;
wokerName = hcmWorkerMan.name();
}
else
{
recipientEmail += strFmt("%1 %2", ";", workerManEmail);
wokerName += strFmt("%1 %2", ";", hcmWorkerMan.name());
}
}
}
}
}
else
{
recipientEmail = hcmWorker.email();
wokerName = hcmWorker.name();
}
if(recipientEmail && emailId)
{
// Build your variable/text mappings
mappings = new Map(Types::String, Types::String);
mappings.insert('Status', enum2str(regTable.status));
mappings.insert('UserName', wokerName);
mappings.insert('RequestNo', regNo);
mappings.insert('RegNote', regTable.registrationNote);
regLine = this.getOverTimeLine();
mappings.insert('RegLine', regLine);
SysEmailTable::sendMail(emailId, //Template
SysEmailTable::find(emailId).DefaultLanguage, // Chosen language
recipientEmail, // Who you're sending the email to
mappings, // Your variable mappings
"", // Location of file attachment (server/client matters) or none
"", // XML if you're using XSLT
true, // Traceable or not?
curUserId(), // Sending user
true); // Use retries?
}
}
