Send Bulk Emails using AXE

Quick Guide >>

The background action feature can be used to send Bulk emails. This page describes the steps needed to set up sending of bulk Emails in your application.

The Axp_MailJobs table holds the records that correspond to the Emails to be sent in the background. This table is available by default.

The structure of axp_mailjobs is as follows :

 

Field Name
Data type
JobDate
DateTime
MailTo
Varchar2(1000)
MailCC
Varchar2(1000)
MailFrom
Varchar2(500)
Subject
Varchar2(1000)
Body
Clob
Attachments
Varchar2(1000)
IViewName
Varchar2(10)
IViewParams
Varchar2(500)
Transid
Varchar2(10)
RecordID
Numeric(16)
Status
Numeric(2)
ErrorMessage
Varchar2(500)
SentOn
DateTime

 

The Status field can have the following values :

0-      New job

1-      Sent

2-      Failed

3-      Do not send

 

How to send Emails in the background

  • Post a record with the relevant details in the axp_mailjobs table.  The posting can be done via Triggers.

See the sample code for a trigger below :

CREATE OR REPLACE TRIGGER TRG_H_MAIL_SENDAFTER UPDATE  ON HOUSELOANAPP FOR EACH ROWDECLARE

ANAME VARCHAR2(100);

BEGIN

IF ( :NEW.APP_DESC=1) AND ( :NEW.ISSUBMIT=’T’)

THEN

INSERT INTO AXP_MAILJOBS(MAILTO, SUBJECT, BODY,  TRANSID, RECORDID, STATUS)

VALUES( :NEW.emailid,  :NEW.APPLICANTNAME || ‘ Your loan application is approved’, ‘APPLICANT NAME – ‘ ||:NEW.APPLICANTNAME || chr(13) || ‘ APPLICATION NO. – ‘ || :new.APPLICATIONNO, ‘tshl’,0,0);

ELSIF ( :NEW.SUBMITTOSCA=’T’) AND  (:NEW.ISSUBMIT)=’F’

THEN

INSERT INTO AXP_MAILJOBS(MAILTO, SUBJECT, BODY,  TRANSID, RECORDID, STATUS)

VALUES( :NEW.emailid, :NEW.APPLICANTNAME || ‘ Your loan application is submitted’, ‘APPLICANT NAME – ‘ || :NEW.APPLICANTNAME || chr(13) ||  ‘ APPLICATION NO. – ‘ || :new.APPLICATIONNO, ‘tshl’,0,0);

END IF;

END;

In the above code,  a record is inserted into the Axp_mailjobs table based on some values .

  • Create a batch file with the  following parameters :

< Axpertscheduler_name>  <Application_Name>  <Admin_UserName>  bulkemail

For eg:

Axe  MyApp admin bulkemail

The given user name will be used as the login user. All access controls are applied on this user. The default action name in this case should be bulkemail.

  • Specify the batch file in the Windows Task Scheduler and set the time trigger as required.

 

Sending an IView result as an EMail

  • Set the IView name in IViewName field in Axp_MailJobs.
  • Set the parameter values in the IViewParams field as name value pairs separated by ~(tilde).

For eg:

To send the “Sales report” to a few people. Set their email id in “MailTo”. Give relevant subject and body. Set the IView name as “Sales report”. If this report takes the month & region as parameters, set their values as Month=Mar~region=south.

  • To send the sales report as PDF set “IVIEW AS HTML” in attachment field.
  • To send the sales report as a word document set “IVIEW AS WORDDOC” in attachment field.

Sending TStruct data & attachments

  • Set the required values into TStruct name & recordid fields. Use the TStruct field names in the Mailto, subject, body or attachment. The field names should be prefixed with colon.

For eg:

To send email to an email address that is in the “myemail” field in TStruct, MailTo field in Axp_MailJobs table should contain :myemail.

  • To send all attachments made to the TStruct as attachment of the mail, store ‘a__*’ in the attachment field.
  • To send the TStruct data in PDF format store ‘p__’+PDF format name in the attachment field.
  • To send the tstruct data in Word format store ‘w__’+Word format name.