Monday, August 19, 2019

Send Report Throw Mail

static void God_sendReportThrowMail(Args _args)
{




    SrsReportRunController                          ssrsController = new SrsReportRunController();
    GOD_GRVReportController             GoodDestructionReportcontroller;


    GOD_GRVReportContract      Contract = new GOD_GRVReportContract();
    SRSPrintDestinationSettings     printerSettings;
       str                             ReportPath;


    // Send Email throw Code

    str             Body;
    str             Subject;
    str             cc1;
    str             mailAddressFrom;
    str             mailAddressTo;
    UserInfo        userInfo;
    SysINetMail mail = new SysINetMail();
    SysMailer           Mailer;
    InventParameters     _InventParameter;
// End

    Mailer  =new SysMailer();

    select _InventParameter;



     ReportPath = "C:\\" + "GRVReportGH" +".pdf";
    Subject = _InventParameter.God_EmailSubject;
    Body = _InventParameter.God_EmailBody;
     ssrsController.parmReportName(ssrsReportStr(GOD_GRVReport, Report_GH));
    ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    ssrsController.parmShowDialog(false);

    Contract.parmRecId(5637144581);
   // Contract.parmRecordId(VendPurchOrderJour.RecId);
    ssrsController.parmReportContract().parmRdpContract(Contract);

    //link the printer settings to the controller
    printerSettings = ssrsController.parmReportContract().parmPrintSettings();
    //print to pdf and always overwrite if the file exists

    printerSettings.printMediumType(SRSPrintMediumType::File);
    printerSettings.fileFormat(SRSReportFileFormat::PDF);
    printerSettings.overwriteFile(true);
    printerSettings.fileName(@ReportPath);
    ssrsController.runReport();

     //assign the values ​​to send email
    mailAddressFrom     = "axsentmails@gxxxxxx.com";
    mailAddressTo       = "axxxxxx@gxxx.com";
    cc1 = "bxxxxx@gxxx.com";


    //Send Mail
    if (mailer !=null)
             {
            mailer.quickSend(mailAddressFrom,mailAddressTo,Subject,Body,cc1,ReportPath);

            //mailer.finalize()

            }




    //mail.sendMailAttach(mailAddressTo,cc1,Subject,Body,false,ReportPath);
   // mailer.quickSend(mailAddressFrom,mailAddressTo,"Attach GRV Report","GRV Report",ReportPath);

   info("Mail Send ");



}

No comments:

Post a Comment