How to email report with the body in D365FO
Microsoft D365 Finance & operations come with the ability to send reports via email and schedule in recurring batches. Print Destination settings give us the flexibility to configure the dynamic value for report email, including Subject, To, CC, attachment file format. Still, it lacks the functionality to include the body along with that email.
Follow the below guide to add body and incorporate it in the email contents.
Time needed: 30 minutes.
Steps
- 1. Create an extension of SRSPrintDestinationSettingsForm
Add form string control for body
- 2. Create an extension class of SRSPrintDestinationSettingsForm to populate mail body on init
- 3. Create an SRSPrintDestinationSettings FormEventHandler class to subscribe formCloseOk delegate
- 4. Create an extension of SRSPrintDestinationSettings class to augment additional functions
a) Create a new Data member attribute for email body
b) Using Chain of command, extend the functionality of parmEMailContract function to set the body in email contract class - 5. In above created SRSPrintDestination Settings, extend the pack and unpack function
Extend the Augmented class macro to include mail body and define logic for pack and unpack using the below implementation. Use the pack-unpack pattern to save and/or store the state of an object, and then later re-instantiate the same email parameters on the next run.
For more information, click the link to follow Microsoft docs on Extending Runbase classes. - 6. Send report email including the body
Now we can include the email body in print destination settings.
The report emailed now includes the body as well and can be further configured for dynamics messages using print management settings based on conditions.
I hope this article helped you learn how to email reports with the body in D365 Finance & operations AX. Don’t forget to share this article. You may also want to see our article on How to use POSTMAN to access D365FO Odata endpoint. You can follow us on facebook for more tips and tricks.
Comments: 3
This is a good write-up.
Docentric is also a great ISV tool that enables some of this functionality in the print management setup.
Thank you.
Yes, Docentric is a great ISV tool. There was a specific requirement by one of our clients which were already developed in Docentric and also they have great articles on google regarding reports and print customizations.
Great article and nicely explained.
I saw that Josh Knox already mentioned that you can use DOCENTRIC and achieve much more like dynamics subjects, body, attachment filenames, advanced recipient selection, etc. All those features are completely FREE. If anyone wants to give it a try, you can download it here: https://ax.docentric.com/download-free-edition/.
To see everything in action, check out our YouTube channel: https://www.youtube.com/playlist?list=PLTIHx8xImydlgBd5rdwsbRU9WQPi_164N
That’s not all. If you want to check what is there for FREE, you can check our feature list here: https://ax.docentric.com/feature-list/