TemplateNotificationGenerator with PDF File from Rapport

19 views Asked by At

as in normal operation, I would like to automatically generate the PDF in the email that is sent.

enter image description here

When I use the code below, no attachment is generated. I would like have the PDF.

enter image description here

          TemplateNotificationGenerator sender = TemplateNotificationGenerator.Create(une_attestation, notification.NotificationID.Value);                        
          sender.MailAccountId = (notification.NFrom.HasValue) ? notification.NFrom.Value : PX.Data.EP.MailAccountManager.DefaultMailAccountID;  
          sender.RefNoteID = un_client.NoteID; 
          sender.LinkToEntity  = true;  
          sender.BAccountID = une_attestation.Atclt;   
     
          sender.RefNoteID = une_attestation.NoteID;
          if ((currentFilter.Usremail!=null) && (currentFilter.Usremail!=""))
            {
              sender.To = currentFilter.Usremail; //un_contact.EMail  
            }

Is it possible to do this without generating the document automatically?

1

There are 1 answers

0
Xavier LARTEM On

I add this code to add the report in the email.

    Dictionary<String, String> parameters = new Dictionary<String,String>();
    parameters["attestationnum"] = edispace(une_attestation.Atnum);
    PXReportSettings settings = new PXReportSettings("SOPRATTT");
    PX.Reports.Controls.Report report = 
    pg.ReportLoader.CheckIfNull(nameof(ReportLoader)).LoadReport("SOPRATTT",null); pg.ReportLoader.InitDefaultReportParameters(report, parameters);
    PX.Reports.Data.ReportNode reportNode pg.ReportDataBinder.CheckIfNull(nameof(ReportDataBinder)).ProcessReportDataBinding(report);
    byte[] data =PX.Reports.Mail.Message.GenerateReport(reportNode,RenderType.FilterPdf).First();                                
    sender.AddAttachment("fiscale.pdf", data);