SrsReportRunPrinter Sent email with template

 SrsReportRunPrinter Sent email with template

Nghia Song - Technical Consultant

/// 
/// extesion of SrsReportRunPrinter
/// 
[ExtensionOf(classStr(SrsReportRunPrinter))]
final class LAW_SrsReportRunPrinter_C_Extension
{
    public SrsReportDataContract  dataContract;
    public PurchPurchaseOrderContract   purchPOContract; 
      

    public str buildEmalBody(PurchId _purchID)
    {
        PurchTable      purchTable = PurchTable::find(_purchID);
        PurchTotals     purchTotals;
        str             emailHeader,emailBody;

        purchTotals     = PurchTotals::newPurchTable(purchTable);
        purchTotals.calc();
        real            totalAmount = purchTotals.purchTotalAmount();
        emailHeader = strFmt('

Dear %1,

',purchTable.vendorName()); emailHeader += '

Good Day.

 

Please see attached P.O. for items to be delivered based on the Shipment date.

'; emailBody += strFmt('',_purchID, totalAmount,purchTable.DeliveryDate,InventLocation::find(purchTable.InventLocationId).Name); return emailHeader + emailBody; } /// /// extens to update Purchase Id incase of docoment called from PurchPurchaseOrderContract rdp /// public void printReport() { RecId recordId; SysIMailerNonInteractive mailerFail; PurchId purchId; Object objRdp = this.reportContract.parmRdpContract(); str emailBody; if (objRdp is PurchPurchaseOrderContract) { purchPOContract = objRdp; recordId = purchPOContract.parmRecordId(); purchId = VendPurchOrderJour::findRecId(recordId).PurchId; emailBody = this.buildEmalBody(purchId); printSettings.parmEMailBody(emailBody); } next printReport(); if (mailer && mailer.emailId) { if (recordId && purchId) { SysOutgoingEmailTable outEmail = SysOutgoingEmailTable::find(mailer.emailId,true); if (outEmail) { outEmail.LawPurchId = purchId; ttsbegin; outEmail.update(); ttscommit; } if (outEmail.Status == SysEmailStatus::Failed) { str toAddress = SrsReportRunMailer::lawBuildUserEmailAddress(PurchTable::find(purchId).CreatedBy); str fromAddress = outEmail.Sender; str mess = strFmt("@LAW:LAW_G02010107_01",purchId); mailerFail = SysMailerFactory::getNonInteractiveMailer(); //send fail email back to sender var messageBuilder = new SysMailerMessageBuilder(); messageBuilder.setFrom(fromAddress) .addTo(toAddress) .addCc("") .setSubject(mess) .setBody(""); boolean result = mailerFail.sendNonInteractive(messageBuilder.getMessage()); //end } } } } }
Store name/WH nameP.O.#P.O. AmountShipment/Delivery Date:
%4%1%2%3
Previous Post
Next Post

post written by: