Report printed to e-mail

You can easily send a D365FO report in email just by configuring print destination to Email and setting a few properties.

You can do the same from code, where you can also set the body. You must create an instance of SrsReportEMailDataContract class, fill it values and pass it to SRSPrintDestinationSettings.parmEMailContract(). Here is an example:

SrsReportRunController controller = new SrsReportRunController();
controller.parmReportName(ssrsReportStr(SysUserRoleInfo, Report));
SRSPrintDestinationSettings settings = controller.parmReportContract().parmPrintSettings();
// Here we configure the email
SrsReportEMailDataContract emailContract = new SrsReportEMailDataContract();
emailContract.parmSubject("Security report");
emailContract.parmBody("Hi there! Here is your report.");


    • A BCC parameter? I don’t see any, only CC (which seems to work fine).

  1. Hello Martin,

    Thank you for the post.
    I want to add a field “emailFrom” to the SRSPrintDestinationSettings but this is a framework class, is there another way to achive that ? (email report from a batch job and use another source email adress instead of the user’s address)
    I tried to redirect the report to SysMailerMessageBuilder using the method descriped here :
    But the report attached is never the good one even though the params are good.


    • Hello,

      The code turns out to be the same: Controller / settings / SRSproxy / SysMailerFactory
      I just had to ajust the missing code from the controller to make it work.


  2. Hi Martin,

    Thanks for always sharing useful information accross all available platforms and foruns.

    Just one note with regards to the email attachment when sending the email via code – To get the correct file extension output from SSRS, the file format property needs to be set in the emailContract class, e.g.:


    If this property is not set, SSRS will produce and attach to the email a file in .csv format which is the first value in the enum SRSReportFileFormat.

    Sharing the info here so if more people struggle to get the correct file format by thinking that only setting the format in the print destination settings is enough – the answer is here 😉

    Best regards.

Comments are closed.