1 min read

Sending emails from Dynamics AX to external domains using Exchange Online

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 outlook.com 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: http://technet.microsoft.com/en-us/library/dn554323(v=exchg.150).aspx

Log in to https://portal.office.com 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.