Monitor and resend outgoing emails with printed invoices in D365FO

In the real world, you may experience timeouts when emailing invoices in batch due to sending limits of Online Exchange. Namely, sending message rate limit is 30 messages per minute, which can easily be exceeded when emailing takes place in batch.

To overcome this problem we can increase the SMTP client timeout. Learn how To overcome this problem we can increase the SMTP client timeout. Learn how >>

However, increasing the SMTP client timeout may not completely solve the problem. Moreover, it would be much better solution to send outgoing emails not synchronously but using a queue. On top of that, it would be great if we could monitor statuses of outgoing emails, perform sending and resending in batch, define retry schedule, etc. Sounds familiar? Yes, it does! In Dynamics 365 for Finance and Operations we can indeed find such a built-in outgoing email queue: System administration > Periodic tasks > Email processing > Email sending status, which is used for outgoing emails for Alerts, Workflow and Retail notifications.

Therefore, we decided to utilize Email sending status for emailing reports and provide this functionality as part of Docentric Free Edition, a completely free D365FO Add-On.

In this article you will learn how to save an outgoing email with a printed invoice to Email sending status, the built-in outgoing email table, instead of sending it in the process of report execution.

Step 1: Set up the report’s Email sending mode to Email processing

When we want to email a report (e.g. an invoice) in D365FO using the Email print destination, it will be emailed synchronously. This means that D365FO will block report execution until it gets some response from the outgoing mail server. In case that sending fails, we will only get an error message from the mail server (e.g. The operation has timed out) without any possibility to resend the failed email. Using Docentric we can change this built-in behavior and instead of waiting for a response from the mail server, we can create emails with printed invoices and save them to the built-in Email sending status table. These outgoing emails will be then sent out from D365FO by Email distributor batch.

In order to achieve this, we have to set up Email sending mode for the Customer invoice report in Docentric report setup (Docentric AX Workspace > Reports).


Docentric report setup provides two options for Email sending mode: Synchronous and Email processing, which can be set per report or even per report per company. Synchronous is the default option, and when selected it means the built-in emailing behavior. Email processing, however, saves emails to Email sending status where they will be processed by Email distributor batch.

Step 2: Activate Docentric email distributor batch

If you are not using any of Docentric’s emailing improvements such as multiple email sender accounts, the Cc and Bcc fields, Reply-to and Bounce-to addresses, Read and Delivery receipts, etc. built-in Email distributor batch will do just fine. However, if you are taking benefits from Docentric’s improvements, you will need to activate and use Docentric email distributor batch.

Docentric email distributor batch can be activated on the Docentric AX parameters form: Docentric AX > Docentric AX parameters > Emailing, by turning on the Use Docentric email distributor batch option.

Only with this option turned on, you will be able to use Docentric email improvements including multiple email sender accounts, which can be set on the same form, instead of the single one set in built-in Email parameters.

When you installed Docentric AX for the first time, the Use Docentric email distributor batch option is turned on by default. But if you upgrade Docentric AX from one of the previous versions you will need to turn it on manually. In both cases however, if you already have Email distributor batch up and running in your environment, you will need to reschedule it, i.e. to stop the batch job and start it again while this option is turned on.

Learn here how to enable logging for Docentric email distributor batch >>

Step 3: Set up Print management settings

For the sake of this example we are going to set up Print management settings for Customer invoice and use it to email the report. Note that you can open Print management setup directly from Docentric report setup.


Select Email as the target print destination. Note that we used placeholders (@InvoiceId@ and @COMPANYNAME@) in the email subject and body. They will be replaced with the corresponding data at runtime.


Step 4: Run the report using Print management

Let’s now open the Invoice journal form: Accounts receivable > Inquiries and reports > Invoices > Invoice journal.

Select an invoice and click the INVOICE > View > Use print management button to run the report.

The invoice will be created and attached to an email, but this email will not be sent. It will be saved to the Email sending status table instead, because we set Email processing as Email sending mode in Docentric report setup for this report.

Step 5: Find the outgoing email in Email sending status

Now that our report has been successfully saved to the Email sending status table, let’s take a look there.

Navigate and open System administration > Periodic tasks > Email processing > Email sending status.

We can see that our email has not been processed yet, since it has Waiting (0) status. Once Email distributor batch runs, the status will change to Sent or Failed, depending on the outcome.

When an email failed to be sent, we can use the Restart send button to trigger new sending.

The Email description field

The Email description field is NOT THE SAME field that contains the email subject, which we specified in Print management settings. The value of this field is set to Report caption. So it makes sense to set up Report caption to contain meaningful placeholders such as @InvoiceId@ and @InvoiceAccount@ and this way enables filtering by Invoice ID and Customer account number.

You can set up Report caption in Docentric report setup for a report to contain any of the placeholders that can be used in print destination settings. This way you will be able to filter Email sending status also by report specific information such as Account number or Document ID.
Learn more about multiple use of Report caption >>

How to start Email distributor batch

In production environments we usually have Email distributor batch scheduled to run periodically in batch, e.g. each 5 minutes, but we can also start it manually to run just once by clicking the System administration > Periodic tasks > Email processing > Email distributor batch menu item.

See also

Log errors of Email distributor batch in D365FO >>
Run Email Distributor Batch for Different Outgoing Emails >>
Batch email sending status improvements >>
What can we do when invoice emailing fails due to SMTP client timeout in D365FO >>

One thought on “Monitor and resend outgoing emails with printed invoices in D365FO

Leave a Reply

Your email address will not be published. Required fields are marked *


Docentric respects your privacy. Learn how your comment data is processed >>

Docentric respects your privacy. Learn how your comment data is processed >>