Tuesday, June 24, 2014

Sending an email with HTML formats

static void BKSendingMailWithHTMLFormat(Args _args)
{

    HcmWorker                   hcmworker,hcmWorkerBuffer;
    int64                               workerRecId;
    SysMailer                       mail;
    str                                  senderEmail,name;
    str                                  recipientEmail,recipientEmail2;
    str                                  messageText, leavetype,letterTemplate;
    Name                            empl, Manager;
    str                                 cc, to, body, sub;
       
    mail = new SysMailer();

    workerRecId = hcmworker::userId2Worker(curUserId());
    select hcmworker where hcmworker.RecId == workerRecId;
    cc = "unknown@gmail.com";
    recipientEmail = "unknown@gmail.com";

    Name = DirPartyTable::findRec(HcmWorker::find(global::currentWorker()).Person).Name;


    sub = strfmt("Regarding Employee Letter Request");

    body = "<html><body>"+ strfmt("Dear %1,",Manager)+ "<br/><br>"+
                        strfmt("%1 being employee Id %2 has Requested for the %3",name,hcmworker.TransferEmployeeCode,letterTemplate) + "<br/><br>";
   
    body = Body + "<html> <body><table border='1'>";

    senderEmail     =   'unknown@gmail.com';
    body= body+  "<tr><td>" +   "Date"    +"</td>";
    body= body+  "<td>" +  strfmt("%1",today())    +"</td></tr>";
    body= body+  "<tr><td>" +   "Employee Name"    +"</td>";
    body= body+  "<td>" +  strfmt("%1",Name)    +"</td></tr>";
    body= body+  "<tr><td>" +   "Letter"    +"</td>";
    body= body+  "<td>" +  strfmt("%1",letterTemplate)    +"</td></tr>";

    Body= Body + "</table>";

    Body = Body + strfmt("<br/><br/><b>Note:This is a system generated email. Please do not reply to this mail.</b> </body></html>");
    mail.quickSend(senderEmail, recipientEmail,sub, Body);


}

No comments:

Post a Comment