Canada
pawan.deep55@gmail.com

How to email report with the body in D365FO

Email x++

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.

Print Destination Settings

Follow the below guide to add body and incorporate it in the email contents.

Time needed: 30 minutes.

Steps

  1. 1. Create an extension of SRSPrintDestinationSettingsForm

    Add form string control for body
    Form extension x++ print destination settings

  2. 2. Create an extension class of SRSPrintDestinationSettingsForm to populate mail body on init


  3. 3. Create an SRSPrintDestinationSettings FormEventHandler class to subscribe formCloseOk delegate


  4. 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. 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. 6. Send report email including the body

    Now we can include the email body in print destination settings.
    OutputBody Print management 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.

Email-with-body
Email-with-body

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.


Author: Pawan Deep SinghI am a D365 Finance & Operations Technical Consultant. I have dedicated this blog to write about all D365FO , ax2012 x++ related tips and tricks I came across in my career. For any query feel free to contact me via the contact section.

 

Comments: 3

  1. Josh Knox says:

    This is a good write-up.

    Docentric is also a great ISV tool that enables some of this functionality in the print management setup.

    • Pawan Deep Singh says:

      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.

  2. Klemen Novak says:

    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/

Add your comment