Request email read receipt in AX2012 via X++

Problem.

There is a need to request email read receipt after sending AX2012 sales invoice via X++, which works the same way as Microsoft Outlook‚s feature to ask for confirmation.

Important: There is no guarantee that this solution will work properly in every situation, because some email servers are rejecting read receipt requests and some users can use email client settings to automatically reject read receipt.

Tool.

We will use standard SysMailer class, which is already present in Microsoft Dynamics AX2012 R3 application. In order to do this, we will create a new method, which will modify email structure to let customer’s email server know that we need read confirmation.

Step by step.

Most email clients are trying to save us from looking at unimportant, for user, details, but every message contains bunch of information about how it should behave. We call it internet headers and they can tell us something about sender, receiver, subject, priority and much more.

Now, we can dig deep into theory, but the most practical way will be to send two different messages from Microsoft Outlook – first without read receipt, second with read receipt (Options Tab > Tracking > Request a Read Receipt) – and then compare these two.

If we have already sent these two emails, after opening one of them, we can find internet headers in message properties (File > Properties) or by selecting the tiny arrow in Message > Tags tab.

Internet messages in Microsoft Outlook
Internet messages in Microsoft Outlook

We got it. The next step is to create two separate text files and copy our headers into them. We can compare these files manually, but the best way is to use some software, which is create to compare content. For this purpose, I used open source WinMerge and here is a quick introduction how to compare two files.

There should be one additional line in message with read receipt request:

Disposition-Notification-To: _____@_____.__

disposition-notification-to Field at MSDN.

If we take a look at SysMailer class, „Importance” flag is already implemented in AX2012 using URN Schema, so we can do this the same way for our read receipt. We will use „urn:schemas:mailheader:disposition-notification-to” as it is defined in MSDN.

We have to add new definition to SysMailer macro:

#define.ReadReceipt ('urn:schemas:mailheader:disposition-notification-to')

We create a SysMailer method:

And now, before invoking sendMail() method, we can use our readReceipt() method and pass an email address, which is requesting read receipt.

Sources:

  • IANA Message Headers
  • RFC4021 Documentation
  • Microsoft Dynamics Community Forum
  • Leave a Reply