Thursday 29 November 2018

Email invoices using built-in email processing in D365FO

In my previous blog I explained how we can email invoices in Dynamics 365 for Finance and Operations with the nicely designed email body and additional email attachments such as Invoice specification or Term & Conditions. Everything worked just fine until we stumbled upon SMTP client timeout when we were emailing invoices in batch, and some emails failed to be sent. The reason was the limitations related to Online Exchange.

In order to resolve SMTP client timeout issue I have done some research on how this can be fixed, and I found the solution within the same free tool (Docentric) we used to email invoices with the nice body and additional attachments.

So, this problem can be solved with Docentric in two ways: 
  • Setting up (increasing) the SMTP client timeout.
  • Using email processing. This means that instead of sending an invoice right away after it is being generated, the invoice will instead be saved to Email sending status, the built-in outgoing email table used, e.g. for workflow email notifications.

SMTP Client Settings:

In Docentric free-edition tool global parameters we can set up SMTP client settings. Beside standard SMTP settings such as Outgoing email server, SMTP port, if SSL is turned on, etc. you can set up also SMTP client timeout, Body and subject encoding, Delivery format, etc.

Navigation: Organization administration -> Docentric AX -> Docentric AX parameters










Monitor & Save Outgoing Emails:

Out of the box in Microsoft Dynamics 365 Finance and Operations when we print an invoice to the Email print destination, it will be emailed synchronously, i.e. in process. This means that D365FO will wait for a response from the outgoing mail server, which can be Success or Failure. In case of Failure we will only get the error message without a possibility to resend the failed email.

Docentric free-edition tool offers the possibility to save outgoing emails with invoices to Email sending status. This is a standard table used for outgoing emails for workflows and retail notifications. The main advantage is that you can monitor the status of outgoing emails and define retry schedule.

Navigation: System administration -> Periodic tasks -> Email processing -> Email sending status

Now let’s demonstrate how to email invoices by using Docentric free-edition tool through Email sending status, i.e. outgoing email table. For this example I used Sales Invoice report which is emailed via Use print management from Invoice journal.

Navigation: Accounts receivable -> Inquiries and reports -> Invoices -> Invoice journal








Step: 1

Docentric report setup provides multiple options. There we can choose Email sending mode (Synchronous or Email processing) per report. If we choose Synchronous, it will run as out of the box, by sending the email with a generated invoice and additional attachments synchronously. On the other hand, if we choose Email processing, the email will be saved to Email sending status, i.e. the outgoing email table from where it will be sent later by Email distributor batch.

Navigation: Organization administration -> Docentric AX -> Reports

By navigating this link, it will open Docentric AX Reports. Click the Settings tab and select Email sending settings as shown on the image below.








When you click the
Email sending settings menu item, it will open a form in which we can select Email processing as Email sending mode. Please see the image below.










That is all you need to do in order to enable emailing your invoices using Email processing

Step: 2

For this example we have used the Sales invoice report, which can be printed using Print management setup, so we will now set up the print management settings.

Navigation: Accounts receivable -> Setup -> Forms -> Form setup -> General (Tab) -> Print management










Select
Customer invoice and click the marked button to change the target print destination.


























Provide To address, Subject and Body, and save your settings.



Step: 3

Now run your Sales invoice report using the Print management option. Please note that when we run the Sales invoice report out of the box without using Docentric Email print destination it will show below message in case of success.







But since we are using Docentric Email print destination with chosen Email processing as Email sending mode for this report, this time the email will be saved to Email sending status, i.e. the outgoing email table, and also the different message will be shown – please check the image below.








Now we can find the email in Email sending status in status Waiting. Here, in this form, you will be able to monitor and see the status of all outgoing emails.

Navigation: System administration -> Periodic tasks -> Email processing -> Email sending status



To send our email from Email sending status, we first have to make sure that we have SMTP server configured and running. Go to System administration -> Setup -> Email -> Email parameters and fill the required settings. Next step is to make sure that Email distributor batch is up and running. Go to System administration -> Inquiries -> Batch jobs and check if the batch job (E-mail distributor batch) exists with status Executing or Waiting. If it doesn’t, you can activate it from System administration -> Periodic -> Email processing -> Email distributor batch.

Now when we run Email distributor batch (as a batch job or without it) it will send all emails with the status Waiting, one by one (with retries and status controlling). The email status will change to Sent or Failed.

























Now refresh the Email sending status form. You can see in the image below that our email is successfully sent.






That is how Docentric free-edition tool helps us to save emails with generated invoices, send them reliably and monitor the progress of sending.

Email sending status enhancements:

Built-in Email sending status is also extended by Docentric free-edition tool.

  • Additional columns.
    • Context information (provides the information about the attached report)
    • Company Id (provides the information about the legal entity)

  • Download message as EML file that can be open with Outlook.

  • Show message is improved to show the list of email attachments as well. You can download one by simply clicking on it.


I found saving outgoing emails with invoices in Email sending status very useful, because we can now monitor and resend them if needed. But there is more what you can do with Docentric free-edition tool. In one of the next articles, I will show you how to email reports with different From email addresses.

No comments:

Post a Comment

How to fix Error: "Common Language Runtime detected an invalid program" in D365FO

Recently, we upgraded our environment, which resulted in one of our customizations, previously working flawlessly, throwing the "Common...