Setup Email Alerts and Send Mail using X++ Code in Dynamics AX

Following steps illustrates how to setup and activate Email Alerts in DAX 2009.
In Ax we have two types of Alerts.
1 ) Pop-Up Alerts , shown in AX Forms as pop-up windows.
2 ) Email Alerts , where alert message will be sent to users by mail.  In other words its extended
version of Pop-up Alerts.
How it Works :
a ) For every alert ax creates record in SysOutgoingEmailTable and 
b ) Then Email distributor batch(Class->SysEmailBatch->run method)  job reads the message
from the above table and after validating execute the mail.
Now we will see what all setups are required for activating second type of alert.
Step1 : Activates the Alerts feature for user in options form .
Go to  Tool–>Options  , set show email alerts  as

Step 2 :  Set Email Parameters , Administration->Setup->Email Parameters
Define parameters like which SMTP  Server to use for sending mails and credentials
by which mail will be sent to users.

Step 3 : Add Email distributor batch to BatchJob Queue. This job will be responsible for sending mails to users. So if you are not receiving any email it means u have not scheduled this batch job to run.

Set the recurrence as No End date and minutes as 15-30 minutes.
Step 4 : Check the Batch Job queue for Email distributor batch job , you should find new record
in batch queue as
Basic–>Inquiries–>Batch Job

For this record Click on Alerts and select check box “Error” . It means whenever this
batch job fails you will get alert.

Incase of any failure you can debugg SysEmailBatch Class run method .
Step 5: Set up Email Templates and attach to EventParameters.
Basic -> Setup -> Alerts -> Alert Parameter.

Step 6 :   Job to test whether u have configured correctly or not.
static void Mail_Send(Args _args)

EventParameters eventParameters = EventParameters::find();
SysUserInfo             sysUserInfo;
UserInfo                userInfo;
// SysUserInfo has Alert and email info
sysUserInfo = SysUserInfo::find(curuserid());
// UserInfo has the language info
//userInfo = xUserInfo::find(false, eventRule.UserId);

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


Get every new post on this blog delivered to your Inbox.

Join other followers:

error: Content is protected !!