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
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/
Pingback: Adding ReplyTo to report print destination | OrganicAX·
Pingback: Adding ReplyTo to report print destination - Microsoft Dynamics AX Community·
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!
LikeLike
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!
LikeLike
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
LikeLike
Pingback: Send report via email additional parameters | OrganicAX·
Pingback: Send report via email additional parameters - Microsoft Dynamics AX Community·
Can you please share the same with html body rather then text only
LikeLike
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
LikeLike
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 🙂
LikeLike
i had forgoten to launch incremental CIL and also did clear cache. now it works!!
LikeLike
ok great you got it to run.
Cheers
Lachlan
LikeLike
Nice one, thanks for this, super with the video and all !
LikeLike