Question
Accenture Federal Services
US
Last activity: 29 Oct 2021 7:13 EDT
Email Attachment through Agent with no Work Item
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.
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:
----------
1. > Obj-Open [TemplateFile] (Class Rule-File-Binary)
2. > Java []
3. > Page-New [AttachmentPage] (Class Data-EmailAttachments)
4. > Property-Set [AttachmentPage]
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:
----------
1. > Obj-Open [TemplateFile] (Class Rule-File-Binary)
2. > Java []
3. > Page-New [AttachmentPage] (Class Data-EmailAttachments)
4. > Property-Set [AttachmentPage]
5. > Call SendSimpleEmail []
6. > 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.