Adding message body text to email destination for reports

I had a request from a customer and did a little investigation into it. They wanted to be able to send an ah-doc report to a customer via email. When you specify the report print parameters you just have a subject line. They wanted to be able to add some message body text. Here is a quick walk through of what that ended up like.

If I had more time there are probably a few things I’d do, one for example be able to select the email template as that they could attach pre-defined “boiler plate” messages. As well as you can see in the walk through this specific function is a client side call to Outlook still using COM. This doesn’t work in a batch process so changing this to a batch process similar to some of the other email sending functional in AX would be useful. See my earlier post on what I mean by client/server.

If you want to have a look at the code sample for R3 you can find it here

https://onedrive.live.com/redir?resid=FD50488EDE1F8A3C!114&authkey=!AEjx4Nv-S_KpSp4&ithint=folder%2czip

There is a model file and a XPO for the project, it should be quite similar for R1/R2. It’s a sample only for you to learn and experiment with for your own modification.

Cheers

Lachlan

Update 2015/4/20.

Follow-Up post here with additional parameters https://organicax.com/2015/04/20/send-report-via-email-additional-parameters/

13 responses to “Adding message body text to email destination for reports

  1. Pingback: Adding ReplyTo to report print destination | OrganicAX·

  2. Pingback: Adding ReplyTo to report print destination - Microsoft Dynamics AX Community·

  3. Hi Lachlan,

    To make this work also on batch jobs, just add the following line to the SRSPrintDestinationSettings class, method parmEmailContract:

    emailContract.parmBody(this.emailBody());

    Thanks!

    Like

  4. Hi Lachlan,

    To make this work also on batch jobs, just add the following line to SRSPrintDestinationSettings class, method parmEmailContract:

    emailContract.parmBody(this.emailBody());

    Thanks!

    Like

    • Thanks
      That is a good prompt to post the follow-up post with the updates for the batch piece. As well the code is different in R2 so I’ll post a follow-up for these.
      Cheers
      Lachlan

      Like

  5. Pingback: Send report via email additional parameters | OrganicAX·

  6. Pingback: Send report via email additional parameters - Microsoft Dynamics AX Community·

    • Hi Fahad
      The aim of the modification I did was to do minimal changes to the standard code. There should be a method/property on the objects to switch to a HTML email message body but then if you want to use the full HTML then you would have to put additional HTML tags into the message to use it hence I just left it as text. I’ll have a look and see if I can suggest something.

      Cheers
      Lachlan

      Like

  7. Hi,
    This is exactly the functionality that I need to implement in a project.
    I need to run and send the report in batch so I used the line: emailContract.parmBody(this.emailBody()), and took of the item.display() in the method smmOutlookEmail.sendEmail().

    I followed your instructions and checked it several times but still does not work..
    Any suggestion please?
    thanks in advance 🙂

    Like

Leave a comment