Kourier Integrator Online Help

Creating Custom Email Messages

You can create and send your own emails and include dynamic message content using Kourier.

To format a message:

  1. Determine which message template to use. This template can be created using E-mail Message Template.
  2. If the message contains dynamic content, determine the source of the data. This is determined by the type of substitution tags contained in the message. Data can contain both database record and program data.
  3. If the message template contains database record tags, then specify the dictionary file pointer. This must be a valid file pointer to the dictionary file that contains the dictionaries specified in the message template. If database record is not used, set this parameter to nil.
  4. If the message template uses the @ID tag, then specify the record ID; otherwise, set this parameter to nil.
  5. If the message template contains database record tags, then specify the record; otherwise set this parameter to nil.
  6. If the message template contains programmed value tags, then specify the programmed data item. The fields in this item are value-mark delimited.
  7. To specify the width of text in the formatted e-mail, specify the width in characters. To use the default of "74," set this parameter to nil.
  8. To use a pre-defined message template, specify the ID of the template. To use a message template from another source, set this parameter to nil and pass the message template in the message parameter.
  9. If a message template is not specified in the message parameter, specify the message template.
  10. Messages are formatted by calling KMK.FMTMAIL.
  11. Messages are delivered by calling KMK.SENDMAIL.

Example

The following example formats a message and passes in a database record and program data. To run this program, create message template MSO-Z001 with the message:

Your customer, {NAME}, has a new telephone number due to a restructuring of area codes in their region. Their new phone number is {PHONE}. Be aware than many of your contacts in area code ({%1}) are subject to change by {%2}.

The following program code formats the message template with information from the cust email:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
* Open The Data And Dictionary Files Of The CUSTOMER File
CALL HW.OPEN('DICT CUSTOMER',FD.CUST,OFLAG,1)
CALL HW.OPEN('CUSTOMER',F.CUST,OFLAG,1)
*
* Find A Customer That Has A New Area Code
STMT = 'SSELECT CUSTOMER WITH PHONE = "[858/]" "[935/]" '
CALL HW.EXECUTE1(STMT, 'CRS', OUT, ERR, SELIST, SELCNT)
READNEXT ID FROM SELIST ELSE STOP
*
* Get The Database Record And Program Data
READ CUST FROM F.CUST, ID ELSE STOP
PARMS = 619 : @VM : 'December 31, 1999'
*
* Use The Default Width
WIDTH = ''  
* Format The Message With The Specified Template 
ETID = 'MSO-Z01'  ;* Email Template ID
CALL KMK.FMTMAIL(FD.CUST,ID,CUST,PARMS,WIDTH,ETID,MSG,ERRNO,ERRMSG)
IF ERRNO THEN
  PRINT ERRMSG
  STOP
END