web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Call and email a report by X++

(0) ShareShare
ReportReport
Posted on by

Dear community members,

I tried to search the forums for a sample of using X++ to call a D365 Finance & Operations report and then email it, but can't seem to find a good place to start.

Basically I am trying to use code to call vendor payment advice report and email it to a vendor email address.

thank you all for reading and helping!

Fen

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,998 Most Valuable Professional on at

    Here is an example:

    SrsReportRunController controller = new SrsReportRunController();
     
    controller.parmReportName(ssrsReportStr(SysUserRoleInfo, Report));
    controller.parmShowDialog(false);
     
    SRSPrintDestinationSettings settings = controller.parmReportContract().parmPrintSettings();
     
    settings.printMediumType(SRSPrintMediumType::Email);
    settings.fileFormat(SRSReportFileFormat::PDF);
    settings.fileName('SysUserRoleInfo.pdf');
     
    // Here we configure the email
    SrsReportEMailDataContract emailContract = new SrsReportEMailDataContract();
     
    emailContract.parmTo("user@example.com");
    emailContract.parmSubject("Security report");
    emailContract.parmBody("Hi there! Here is your report.");
     
    settings.parmEMailContract(emailContract);
     
    controller.startOperation();

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi Fen,

    You don't need to use X++ for that but can make use of the business reports and electronic reporting. There are build in standard features to send them automatically out by email.

    Best regards,

    Ludwig

  • Camilo Fer Profile Picture
    12 on at

    Hi Martin,

    I'm using the code that you show like example and works fine from a job (only for test); but when I use a web service it doesn't due to the default email to send.

     how can I set a "from email address"?

    Thanks for your help!

  • Martin Dráb Profile Picture
    237,998 Most Valuable Professional on at

    Hi Camilo, please never describe your problem by mere "it doesn't work", because there is no universal solution for all possible problem. We need to know what happens in your particular case.

    What did you find when you debugged your web service?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 677 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 442 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 339 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans