programming cusoon
Programming CUSoon is surprisingly simple. It is also surprisingly powerful. Programming is composed of two simple steps: creating of list of extracted data on your host computer and creating an email template (in both plain text and HTML formats) to receive that data: An example of plain text- and HTML-formatted templates appear in the next section, along with the introduction of a new CUSoon-specific tag <cu ...>. CUSoon also possesses the powerful capacity to manipulate the extracted data before it is inserted into the template, and this attribute is explained in the final section: Before you begin programming, you may wish to review CUSoon's philosophy. A brief summary of CUSoon's method of operation is presented in the technical fact sheet:
CUSoon uses the concept of "watched folders" on your host computer(s). When a flat file containing a list similar to one below is placed in the watched folder (or a specified group, in the case of the HP3000's MPE), CUSoon will — on a regular basis — query the folder using FTP to see if one or more files exist in the folder. If the files exist, they are downloaded one at a time, processed and then sent out to their intended recipients. The process is repeated until all of the files in the watched folder have been downloaded and purged from the host. As explained in the Installation Instructions, you may specify five different folders to be watched in CUSoon. Those folders may be on five different hosts, all on one, or in any combination. To create a list of information to be emailed to the various recipients, use your favorite query language to create a list similar to this: Although the text above has been aligned so that all of the colons and equal signs appear in the same column, that alignment is not required. Items that appear before the first colon or equal sign in a row are taken to be the variable names. Items that appear afterward are read as the values. All leading and trailing spaces are trimmed from the resulting text. Information for each individual recipient must be separated by three greater symbols (">>>") on a line by itself. Three pieces of information are mandatory in the list. A list isn't complete without each of these:TO: lmichols@miamibeach.fl.us DOCUMENT: bounced SUBJECT: Insufficient Funds Notice LAST = MICHOLS FIRST = LINDA COMPANY = City of Miami Beach ADDRESS1 = 1100 Washington Avenue ADDRESS2 = Fourth Floor CITY = Miami Beach STATE = FL CHECK = 33139 >>> TO: brian.krasavge@eastman-kodak.com DOCUMENT: bounced SUBJECT: Insufficient Funds Notice LAST = KRASAVAGE FIRST = BRIAN COMPANY = Eastman Kodak Co ADDRESS1 = 1669 Lake Ave ADDRESS2 = CITY = Rochester STATE = NY CHECK = 14652 >>> TO: fbraesek@miamibeach.fl.us DOCUMENT: bounced SUBJECT: Insufficient Funds Notice LAST = BRAESEKER FIRST = FRED COMPANY = City of Miami Beach ADDRESS1 = 1100 Washington Avenue ADDRESS2 = Fourth Floor CITY = Miami Beach STATE = FL CHECK = 33139 >>> The various document specification tags are: TO: If you specify the FORMAT of the emails to be transmitted in your retrieved list, that specification will override the formatting specifications that you have selected in CUSoon's configuration pulldown menu. Otherwise, including the FORMAT: specification is not necessary. Document specifications are noted through the use of a colon (":") and they must come first in each record. Variables are noted with the use of an equal sign ("="). One thousand variables may be specified to be included in each email letter, although it is our expectation that you will only use a few dozen at the extreme. If HTML email is to be sent, a proper template (e.g., "welcomeletter.html") must be present in the /templates folder on the PC from which CUSoon is executing. Similarly, and virtually always required, a plaintext template (e.g., "welcomeletter.txt") must also be present there. However, if HTML email is never meant to be sent, the HTML-based document is not necessary. The DOCUMENT: value can be specified in any of these manners: DOCUMENT: welcomeletterAll three of these notations are equivalent. The file extension at this point is irrelevant. When the document value is read, its extension is stripped off by CUSoon to get the name of the general document. The ".html" and ".txt" extensions are added back on to the document's name just before the appropriate document template, either plaintext or HTML, is to be retrieved. For your use, an example of an "insufficient funds notice" template appears throughout this section. A "plaintext" template in CUSoon is not plain text in the way that you might expect. Because CUSoon is intended to replace variables with their appropriate values, CUSoon requires the use of the <br> (linebreak) and <p> (new paragraph) HTML-like tags in order to provide a well-formatted document. CUSoon uses these tags to create the text structure in the manner that you specify it — after all variable substitution has occurred. CUSoon wraps the substituted text at line lengths of 72 characters or less so that it will appear appropriate and well-formatted to virtually all plain text email readers. The HTML rules for the <br> and <p> tags, which CUSoon also obeys, are as follows:
The <br> and <p> tags disappear from the plaintext output as they are consumed by CUSoon in reformatting the text and are not transmitted. The same is true of the <cu ...> tags, which are consumed when performing the variable substitutions. All other HTML tags are left in the plaintext document. Whether using other HTML tags in a plain text document is a good idea or not depends greatly on the email reader used by the recipient. Most plain text readers will now support some portion of the HTML set of tags, most especially bolding, underlining, italicizing and hyperlinks, but not all do and their use is probably discouraged in plain text templates. An example of a plain text CUSoon template:
<p> A matching HTML template for same "insufficient funds notice" emailing appears below. It is organized as an HTML table, containing three columns. The leftmost column is for a large image. The middle column is an empty, thin gutter column. The right column contains a header (written as an GIF image) and the appropriate text:
<p> The resulting "insufficient funds notice" HTML emailing appears below, with data filled in:
|
Unfortunately, we think that's true too, Wayne. We've had to return your check No. 12345 for $10,000.00 unpaid and your account has been charged a $21.30 handling fee. Please call your customer service representatve at 505.555.5555 or click here for more information. First Universal FCU |
Variable substitution is accomplished using the CUSoon-specific tag <cu ...>. Variable substitution in CUSoon can be as simple as <cu check>, where the check value that was specified in your query-extracted list is substituted into the text. However, significant text and numeric processing capabilities are also a part of CUSoon and a tag such as <cu name(first & " " & last)> is just as easily accomplished (where the first and last names of the recipient are concatenated with an intervening space and appropriately capitalized). Further, new variables, such as "first", can be created within the body of the emails using the DEF construct, as outlined below. Once defined, they can be used elsewhere in the text. In this instance, presume that WHOLENAME is extracted from the host's database in this form: ROGERS/WAYNE, and the first name needs to be properly parsed and capitalized. All of this is accomplished in the first DEF statement: <cu def first:name(sub(wholename,pos(wholename,"/")+1))> Because the <cu def ...> construct is only defining a new variable, it has no impact on the formatting of the document that will be eventually outputted and can be placed anywhere in the text. However, it must occur prior to the first use of the defined variable, as it must in any similar computer language. D. CUSOON FUNCTIONS arithematic operators^ exponentiontext operators
|