Microsoft Dynamics 365 Blog

When using Exchange Online as your SMTP server in Dynamics AX 2012, you may have encountered this issue when sending emails, for example notifications, by batch:

Method ‘send’ in COM object of class ‘CDO.Message’ returned error code 0x8004020F (<unknown>) which means: <unknown>.

The error only occurs when sending emails outside of your organization’s domain, for example to an email address.

In your test environment you can make a small change to the sysmailer class to get more details on the exception. Basically add a try/catch block as follows:

Compile CIL (incremental), restart your AOS and test again. This time you will get a more detailed error message:

The server rejected one or more recipient addresses. The server response was: 550 5.7.0 Relay Access Denied.

To resolve this issue you have to configure a connector in your Exchange Online.

You will find the details here:

Log in to with your Admin account, then go to Admin > Exchange > Mail flow > connectors.

In the Incoming connectors section click on the + sign and configure your connector in order to allow SMTP relay from your AOS. This is just an example, you should be more restrictive:

  • Connector type: On premises
  • Opportunistic TLS
  • Domain restrictions: None
  • Scope: *
  • Sender IP Addresses: external IP address of the AOS

I hope this helps.


We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!