I am trying to fulfill a business requirement in which I need to automatically send an email (through an agent) that will send out an excel report attached to the email. I know that I can schedule reports on the report tab, but this is a custom report that does not show up with that option. I have searched through Pega Community and through the other people at my company and so far no one has been able to help me.
Currently I am doing the following:
Call MSOExcelDownload (This downloads the file exactly as I would expect)
Page-New => AttachmentPage (class Data-EmailAttachments)
Property-Set => pyData, pyName, pyRemoveXML, pyType, and pyDecode on AttachmentPage
Call SendSimpleEmail (This has been heavily modified in our application to email according to business needs)
As of now, the activity runs and sends out an email with an attachment, but the attachment is only the binary file for the template and contains no information. This is because I am passing the TemplateFile.pyFileSource in for pyData on the AttachmentPage. I cannot find the file source for the downloaded attachment once its been created. Any help or suggestions with this would be highly appreciated. Thanks.
I tried using the OOTB report scheduler to send out the report, and it works, except that I need to change the format of the exported excel attachment created by the scheduler. Is there a way to change the format of the excel file from the scheduler similar to the way that we can use binary files as a template to create custom excel files?
Here is the solution that I came up with as the OOTB scheduled reports lack of customization on the excel file did not meet business requirements:
I am running an activity through a scheduled agent. That activity call another activity whose class is Code-Pega-List and the context is the data page or page list that you want to use for the Excel’s data. In this activity I added the following steps:
*PropertiesName *PropertiesValue
.pyAttachments(<APPEND>).pyData = Param.pyAttachStream (the base 64 returned from the java step)
.pyAttachments(<LAST>).pyName = Param.DownloadFileName (the desired name of the file attached to your email)
.pyAttachments(<LAST>).pyType = Param.TemplateFileExtension (the excel file extention, most likely xlsx in this case)
.pyAttachments(<LAST>).pyDecode = true (decode from base 64)
.pyAttachments(<LAST>).pyRemoveXML = false (we are not generating from xml)
Call SendSimpleEmail
Page-Remove [TemplateFile]
Note that I had to modify the SendSimpleEmail activity to take the AttachmentPage we created here instead of the one generated in the activity (how you accomplish that is up to you). Then you can either pass in your parameter values from a calling activity or add a property-set to the start of the activity to set up your parameter values and you should be sending Excel attachments via emails without needing a work object.