AX 2012. SysEmailDistributor does not send emails to multiply recipients.

We have a couple of modifications that use SysEmailTable::sendMail() to send emails and found that if you pass multiple recipients into _emailAddr parameter AX will send email only to last recipient.

This issue was introduced with SysMailerNet in R3. In previous version we were able to pass multiple email addresses using a semicolon as delimiter. Now each email address should be added using SysMailerNet.tos.add() method.

However SysMailerNet::quickSend() method does not have this issue, so we can use it as an example to fix SysEmailDistributor.

Let’s modify SysEmailDistributor::processEmails() method. In standard code we can see that recipient from outgoingEmailTable is passed to mailer.tos().

//instantiate email
mailer.fromAddress(outgoingEmailTable.Sender,outgoingEmailTable.SenderName);
tos = mailer.tos();
tos.add(outgoingEmailTable.Recipient);

To fix our issue we need to split emails and pass them to tos.add() in a loop.

//multiple recipients fix -->
List emailAddresses;
ListEnumerator enum;
//multiple recipients fix <--

…

//instantiate email
mailer.fromAddress(outgoingEmailTable.Sender,outgoingEmailTable.SenderName);
tos = mailer.tos();
/* Orig -->
tos.add(outgoingEmailTable.Recipient);
Orig <-- */
//multiple recipients fix -->
emailAddresses = SysEmailDistributor::splitEmail(outgoingEmailTable.Recipient);
enum = emailAddresses.getEnumerator();
while (enum.moveNext())
{
    tos.add(enum.current());
}
//multiple recipients fix <--
 

By the way this issue is fixed in AX 7.

Advertisements