Sending email receipts from Retail EPOS Transactions (AX 2012)

There seems to be limited information on how the “Send email receipts” functionality works.  This blog is intended to help provide the basic information and links on how to configure and send email receipts for EPOS transactions.

NOTE: For emailing MPOS receipts, see the following blog: Sending email receipts from Retail MPOS transactions

To get started, you will first need to configure a SMTP server to send the emails.  The link below will take you to the TechNet article that walks you through the steps to configure this.

IMPORTANT NOTE:  At the time of writing this article, the sendEmail method in the RetailTransactionService class does require the use of SMTP to send email receipts.  It may be possible to customize this if you would like to use an Exchange service, but it is not supported at this time.

Configure email functionality in Microsoft Dynamics AX
https://technet.microsoft.com/en-us/library/aa834374.aspx

You will then need to configure the email receipts settings in the Retail.  There are 3 options for how receipts will be printed/sent: POS, e-mail, or both.  You can set these to be specific to a Customer or in the Retail parameters.  The Retail parameters setting will be used when you ring up a transaction at the EPOS without a customer.  See the TechNet link below for details on setting these configurations.

Set up email receipts
https://technet.microsoft.com/en-us/library/hh597117.aspx?f=255&MSPPError=-2147217396

Set default options for email receipts
1. Click Retail > Setup > Parameters > Retail parameters.
2. Click the Posting tab, and then under Email receipt, in the Receipt option field, select an option as the default:
◦ POS – Print receipts from the point-of-sale register.
◦ E-mail – Send receipts to customers in email messages.
◦ Both – Print receipts from the point-of-sale register and send receipts to customers in email messages.
3. In the Subject field, enter the text that appears by default in the subject line of a receipt that is sent as an email message.
4. In the File name field, enter the file name for the attachment such as “ContosoSalesReceipt”. Do not include the file extension.
NOTE: You will need to following KB in order for the entered File Extension name to be used:
– KB 3147122 – Emailed receipts do not use the file name specified in the retail parameters
https://fix.lcs.dynamics.com/home/index/373711/kb/3147122

Set email receipt options for a customer
1. Click Accounts receivable > Common > Customers > All customers.
2. On the All customers list page, select a customer, and then, on the Customer tab, in the Maintain group, click Edit.
3. In the Customers form, on the Retail FastTab, select an option in the Receipt option field:
◦ POS – The customer will receive only printed receipts. The printed receipt is generated from the point-of-sale register.
◦ E-mail – The customer will receive only email receipts.
◦ Both – The customer will receive both a printed receipt and an email receipt.
4. In the Receipt email field, enter the customer’s email address if you selected either E-mail or Both in the Receipt option field.

Depending on the settings that you configured, you will need to run the respective Distribution schedule jobs to sync these changes to POS.
1. 1010 – Customer
2. 1110 – Global configuration

When you launch POS and process a transaction for a customer with the option to email the receipt, you will be prompted to enter the “E-mail address for receipt”.  This does perform a quick validation on the entered text to ensure it is in an email address format.

Run the P-job to sync your POS transactions back to AX.  Even though the transaction is now in the RetailTransactions tables in AX, we are not able to send the receipts yet.  The RetailEmailReceipts class is looking for transactions with an RetailEntryStatus of Posted.

Generate a new statement for the store.  Perform the Calculate Statement and Post Statement processes to post POS transactions.

Now run the “Send email receipts” periodic process under Retail >> Periodic to send out the receipts to the customers as PDF attachments.  The attachments are created from a SSRS report named RetailTransactions.  If these are processed in batch, it will use the AOS to send emails from the configured SMTP server.  Be aware that if this is ran outside of batch, it will attempt to send the emails through the local computers default email client.

If we were to look in the AX database at the RETAILTRANSACTIONTABLE table, there is a RECEIPTEMAIL field with the customers associated email address and a RECEIPTEMAILSENT (only in AX database) field that indicates if the email has been sent.  RECEIPTEMAILSENT is initially set to 0 and will be set to 1 after the “Send email receipts” has successfully processed.

NOTE: The steps above are the out of box design to only send emails after the statement is posted, which would be at the end of the day for a normal business scenario.  I understand that this may not meet customer expectations as the expectation is that receipts are received within minutes of the transaction.  In order to send the emails at a higher interval outside of posting the transactions on a statement, you can customize the process by starting to look at the RetailEmailReceipts and RetailEmailReceiptSenderBatchJob Classes.

There are probably various customization options that you could use to send these emails receipts.  Feel free to let the community know your ideas by using the comments section below.