home *** CD-ROM | disk | FTP | other *** search
/ PC World 1999 September / PCWorld_1999-09_cd.bin / Software / Servis / Pegasus / w32-311.exe / TEMPLATE.TXT < prev    next >
Encoding:
Text File  |  1999-04-13  |  18.2 KB  |  426 lines

  1. ----------------------------------------------------------------------
  2.                      Pegasus Mail Message Templates
  3. ----------------------------------------------------------------------
  4.                           Pegasus Mail System, 
  5.        Copyright (c) 1990-99, David Harris, All Rights Reserved.
  6. ----------------------------------------------------------------------
  7.  
  8.  
  9. Contents:
  10.  
  11. 1:      Overview of Message Templates
  12. 2:      Types of Templates
  13. 3:      Using Templates within Pegasus Mail
  14. 4:      The Message Template Script Language
  15.   4.1:  String literals
  16.   4.2:  Command substitutions
  17.   4.3:  Script language commands
  18.  
  19.  
  20. 1: Overview of Message Templates
  21. --------------------------------
  22.  
  23. Imagine that you're the web master for your Internet site; you receive a
  24. huge amount of mail for much of which the answer is essentially the
  25. same... You laboriously reply to the message, remove the pieces you don't
  26. want, type in your canned response, then send the message. Wouldn't it be
  27. good if there was some way of automating all of this? Well, there is --
  28. Message Templates.
  29.  
  30. A Message Template is simply a script that tells Pegasus Mail how to
  31. compose a mail message. The template script commands allow you to set any
  32. address or feature field, include the original message for replies (or a
  33. portion of the message), change or modify addresses, add attachments and
  34. generally give you complete control over the shape of your automatically-
  35. generated message. What's even better, you can define variables in
  36. templates: when you use the template, Pegasus Mail will prompt you for
  37. values for the variables it contains; the script language can then take
  38. the values you enter, manipulate them, and insert them seamlessly into
  39. the generated message.
  40.  
  41. Using a message template, you can generate a complex mail message and
  42. send it with only a couple of keystrokes.
  43.  
  44. What uses might you have for a template? Here are some ideas:
  45.  
  46.    * Helpdesk submissions (as per the sample HELPDESK.PM5 template)
  47.  
  48.    * Mail server management forms (to simplify the process of
  49.      subscribing to and unsubscribing from lists)
  50.  
  51.    * Forms: any kind of complex data-entry based mail form could
  52.      be generated using a template
  53.  
  54.    * Order submission
  55.  
  56.    * Automated replies
  57.  
  58.  
  59. 2: Types of templates
  60. ---------------------
  61.  
  62. Pegasus Mail supports two types of templates - those used to create new
  63. messages from scratch, and those used to create replies to messages.
  64. Template files are simply plain text files containing template script
  65. language commands, one per line.
  66.  
  67. Templates used to create new messages have the extension .PM5; the name
  68. portion can be anything you wish.
  69.  
  70. Templates used to create replies to messages have the extension .PM6; once
  71. again, the name portion can be anything you wish.
  72.  
  73. For both types of template, the script language's TITLE command must be
  74. the first line in the file, so that Pegasus Mail can show the name in its
  75. selector window. Pegasus Mail will not burrow through a template file
  76. looking for a TITLE command if it is not on the first line.
  77.  
  78. Template files can be located in your home mailbox directory, or may be
  79. placed in the same directory as the Pegasus Mail executable program, in
  80. which case they become system-wide and are made available to all users
  81. running that copy of the program. There is no effective limit on the 
  82. number of templates you can define.
  83.  
  84. For now, in order to create a template file you must use a text editor of
  85. some kind - for instance, the Windows NOTEPAD applet. If you use NOTEPAD,
  86. make sure that the Wordwrap option is turned off - each line in a
  87. template file must contain a single command and you cannot run lines 
  88. together. Future versions of Pegasus Mail may include a user-interface for
  89. creating template files.
  90.  
  91.  
  92. 3: Using templates within Pegasus Mail
  93. --------------------------------------
  94.  
  95. You can create a new message using a template by selecting Template...
  96. from the New Message submenu of the File menu. This will open a dialog
  97. listing all the templates available on your system. Select the template
  98. you want to use by highlighting it and clicking Open, or by double-
  99. clicking it. A window will open prompting you for any variables the
  100. template uses; at this point, you can choose whether to open a new
  101. message editor window filled out with the message created by the
  102. template, or simply to send the message without further ado.
  103.  
  104. You can use a template to create a reply to a message in one of two ways:
  105.  
  106. 1: Right-click the message and choose "Reply using template..." from
  107.    the popup menu
  108.  
  109. 2: Highlight the message, then hold down <Shift> as you press the
  110.    "Reply" button, or else hold down <Shift> and press the R key.
  111.  
  112.  
  113.  
  114. 4: The Message Template Script Language
  115. ---------------------------------------
  116.  
  117. The script language used by Pegasus Mail templates is very simple. Each
  118. command in the file must appear on a single line of its own -- commands
  119. may not wrap lines, nor may more than one command appear on a single
  120. line. Lines starting with \, * ; or # are treated as comments and are
  121. ignored.
  122.  
  123.  
  124. 4.1: String literals
  125.  
  126. Most template script commands in the language accept strings as
  127. parameters. String literals of this kind must be entered in quote
  128. characters if they contain spaces or special characters.
  129.  
  130. For example, if you want to use the "insert" command to write the string
  131.  
  132.    Mary had a little lamb
  133.  
  134. into an outgoing message, you would need to enter the command like this:
  135.  
  136.    insert "Mary had a little lamb"
  137.  
  138. since otherwise, only the word "Mary" would be inserted.
  139.  
  140. If your string contains a quote character, or a backslash character, then
  141. you will need to perform a small amount of conversion. So, if you want to
  142. insert the string
  143.  
  144.    Mary had a "little" lamb
  145.  
  146. you would have to enter the "insert" command like this:
  147.  
  148.    insert "Mary had a \"little\" lamb"
  149.  
  150. These rules for string construction apply in all places throughout the
  151. script language.
  152.  
  153.  
  154. 4.2: Command substitutions
  155.  
  156. Practically any string parameter to a script command can contain command
  157. substitutions: these are special character sequences that are replaced by
  158. variables or other information when they are encountered. Pegasus Mail
  159. recognizes the following command substitutions in any place where they
  160. may be used:
  161.  
  162.    ~vvariable_name~   The current value of a template script variable
  163.    ~z                 A single newline (CR/LF)
  164.    ~f                 The "from" field of the original message
  165.    ~s                 The "subject" field of the original message
  166.    ~r                 The preferred reply address for the message
  167.    ~kfieldname~       Any field from the original message
  168.    ~n                 The current user's basic username
  169.    ~i                 The current user's Internet e-mail address
  170.    ~8                 The current user's username truncated to 8 chars
  171.    ~p                 The current user's personal name preference
  172.    ~d                 A random integer expressed as 4 hex digits
  173.    ~y                 The current date and time in RFC822 format
  174.    ~%name%            The value of environment variable %name%
  175.    ~lname~l           The user's address looked up from a synonym file
  176.    ~a                 The Pegasus Mail executable directory
  177.    ~h                 The current user's home mailbox
  178.    ~w                 The current user's new mailbox
  179.    ~~                 A single tilde (~).
  180.  
  181. Examples:
  182.  
  183.    Assuming that the current user's name is "david" and the variable
  184.    "sub" has been assigned the value "your order", the string
  185.  
  186.       "This is a message from ~8, regarding ~vsub~"
  187.  
  188.    would yield the following string after substitution:
  189.  
  190.       "This is a message from david, regarding your order."
  191.  
  192. Command substitution is the single most powerful feature of the scripting
  193. language used for templates, and a good understanding of what it can do
  194. is essential for writing useful scripts.
  195.  
  196.  
  197. 4.3: Script language commands
  198.  
  199. The following commands are valid in template scripts.
  200.  
  201.    title      Set the title for a template script
  202.    helpfile   Set the help file for a template script
  203.    picture    Add a picture to the variable prompt dialog
  204.    text       Add a line of informational text to the prompt dialog
  205.  
  206.    string     Create a string variable for the script
  207.    set        Set a message field or variable value
  208.    insert     Write a formatted line into the message body
  209.    include    Include a file or the original message body
  210.    attach     Attach a file to the message
  211.  
  212.    extract    Extract elements from an e-mail address
  213.    lookup     Look up an item from a list using a key value
  214.  
  215.  
  216. # title <string>
  217.  
  218. Set the title for the script file. string can be any string up to 50
  219. characters in length, and can contain all command substitutions except
  220. for variables, which are not defined at the time this command is
  221. processed.
  222.  
  223.  
  224. # helpfile <filename> [section]
  225.  
  226. Set the help file which should be accessed when the user clicks the Help
  227. button in the variable prompt dialog. filename should be a full reference
  228. to any valid Windows Help file (*.HLP) on your system, and may contain
  229. all command substitions except for variables, which will have not been
  230. defined at the time this command is processed. section is an optional
  231. integer value that indicates the context help section within the help
  232. file that should be presented when the help button is pressed. If it is
  233. absent, section 0, the table of contents, is presented.
  234.  
  235.  
  236. # string <name> ["Default"] ["Prompt"] [len] [flags]
  237.  
  238. Define a variable for use within the script. A maximum of 20 variables
  239. may be defined for any script. name is the name for the variable; it must
  240. not contain spaces, and is not case-sensitive (so var1 and VAR1 are
  241. considered the same). All the parameters following the name parameter are
  242. optional, and you can end the string early if you wish (you cannot omit a
  243. parameter if you need to supply a parameter following it on the line).
  244. "default" is a string which should be used as a default value for the
  245. variable: if it contains spaces or special characters, it must be
  246. enclosed in quotes (see "String literals", above, for more information).
  247. If this parameter is omitted, the default value is an empty string.
  248. "prompt" is the string Pegasus Mail should place next to the editing field
  249. in the variable prompt dialog. If omitted or zero-length, Pegasus Mail
  250. will not prompt the user for a value for this variable. "len" is an integer
  251. defining the maximum allowable length of this variable. If omitted, the
  252. default is "no limit". "flags" defines the format and type of the variable:
  253. the following flag values are available:
  254.  
  255.    multiline       creates a multi-line variable
  256.    address         creates an e-mail address variable
  257.    filename        creates a filename variable
  258.    password        creates a password variable
  259.    list            creates a list - see below for more details
  260.    uppercase       specifies that the variable must be all in uppercase
  261.  
  262. Only "uppercase" may be used with other values.
  263.  
  264.  
  265. Creating LIST variables
  266.  
  267. When you use the LIST flag in a STRING statement, you create a variable
  268. that has a list of possible values from which the user can select. LIST
  269. variables require that you provide a DEFAULT value for the variable,
  270. which contains the list of possible values the variable can have. The
  271. first character in the default value should be the character used to
  272. separate the list items from each other, and the remainder of the default
  273. value should be the items, separated by that character.
  274.  
  275. Example: you want to allow the user to select from the values "Red",
  276. "Green" and "Blue": your string statement would look like this:
  277.  
  278.    string v1 ";Red;Green;Blue" "Select a colour" 0 list
  279.  
  280.  
  281. # set <field> = <"value">
  282. or set variable <variable_name> = <"value">
  283.  
  284. The first form of this command sets a field within the mail message being
  285. generated to the specified value. field may be one of the following: 
  286.  
  287. to, cc, bcc, reply-to, subject (all take a string value)
  288. urgent, confirm-reading, confirm-delivery, copyself, mime ("Y" or "N")
  289. header (a fully-formed e-mail header including the keyword)
  290. volatile (forces the message to be written to final form immediately)
  291. encrypted ("encryptor_name", "password", "flags" - see below for details.
  292.  
  293. When encrypting a template message, use the encrypted parameter to the
  294. set command. encryptor is the name of the module which should be used for
  295. encryption - to use the Pegasus Mail built in encryptor, use the name
  296. "builtin". "password" is the password for the message - this can be up to
  297. 96 characters in length. "flags" controls the type of encryption
  298. performed; to encrypt a message, set it to 1; to add a digital signature
  299. to the message, set it to 4; to perform both operations, set it to 5.
  300.  
  301. The second form of the "set" command sets the value of any defined
  302. variable.
  303.  
  304. Both forms of this command support all command substitutions for the value
  305. parameter. To copy the value of one variable to another, use an
  306. expression containing the ~v command substitution, like this:
  307.  
  308.    set variable v1 = "~vv2~"
  309.  
  310.  
  311. # insert <"string">
  312.  
  313. Write data into the body of the message being generated. string can
  314. contain any command substitution: if it does not contain a ~z
  315. substitution to force a line break, then the next insert command will
  316. write data onto the same line in the body. A single insert command may
  317. not insert more than 1024 characters into the message body.
  318.  
  319.  
  320. # include <filename> [count] [flags]
  321. or include message [count] [flags]
  322.  
  323. Include either a text file, or the body from the message to which a reply
  324. is being generated. The text from the file or message is included as-is
  325. into the message body - command substitutions are not performed on the
  326. included data. The filename parameter may contain any valid command 
  327. substitutions. If "count" is present and non-zero, only that many lines of
  328. the included file or the body of the included message will be read. The
  329. "flags" item can be any combination of the following values:
  330.  
  331.    quoted     "Comment-out" the included text using "> "
  332.    noheaders  If the file is a message, omit its RFC822 headers
  333.    keyheaders If the file is a message, include only "significant" headers
  334.    nobody     If the file is a message, omit the message body
  335.    message    Only valid for files: the file is an RFC822 message
  336.  
  337.  
  338. # attach <filename> [type] [encoding] ["Desc"]
  339.  
  340. Attach a file to the generated message. Only "filename" is a mandatory
  341. parameter - the others can be omitted and are sensibly defaulted. Any
  342. valid command substitution can be used in the filename. If the filename
  343. contains spaces, it must be quoted. "type" is any string describing the 
  344. type of the file - for instance, "RTF_FILE". It must not contain spaces
  345. and is not constrained to the list of possible values inside Pegasus Mail
  346. itself. "encoding" is an integer value that specifies how the file should
  347. be encoded for transfer; the following values are defined - 0 (Pegasus
  348. Mail decides), 1 (No encoding - very dangerous), 2 (ASCII text), 3
  349. (UUencoding), 4 (BinHex 4.0) and 5 (Basic MIME encoding). Unless you are
  350. sure of what you are doing, use 0 for this field. "desc" is a textual
  351. description of the file; it may contain any text, including spaces, and
  352. is truncated at 63 characters.
  353.  
  354.  
  355. # picture <flags> <filename>
  356.  
  357. Add a picture at the top of the variable prompt dialog. The picture
  358. specified by filename must be a Windows BMP file in 16 or 256 colours:
  359. owing to quirks in the way Windows handles 256 colour bitmaps, we
  360. strongly recommend that you use 16-colour bitmaps if your display runs in
  361. 256 colour mode or lower. For the Win16 version of Pegasus Mail, the
  362. bitmap must not be larger than 60,000 bytes. You may use any command
  363. substitution in the filename parameter. The bitmap is centred 
  364. horizontally in the display and the dialog will adjust size to fit the
  365. vertical dimensions of the image. Exactly one image may be added to the
  366. dialog.
  367.  
  368. flags will be used in future to offer extra formatting options. For now,
  369. it is unused, must be present, and should be set to zero.
  370.  
  371. Note: if the filename contains spaces or special characters, it must be
  372. enclosed in quotes.
  373.  
  374.  
  375. # text <flags> <"string">
  376.  
  377. Add a line of descriptive text to the dialog presented to prompt for
  378. script variables. The line of text is added above any variable editing
  379. fields, and below any picture defined using a picture command. You may
  380. specify up to 10 lines of descriptive text, and each line may contain any
  381. valid command substitution. The "flags" parameter will be used in future,
  382. but should currently be set to zero.
  383.  
  384. To introduce a blank line between groups of lines, use a text statement
  385. with an empty quoted string - like this: text "".
  386.  
  387.  
  388. # extract address <var1> <var2>
  389. or extract text <var1> <var2>
  390. or extract user <var1> <var2>
  391. or extract domain <var1> <var2>
  392.  
  393. Extract a component from an e-mail address. "var1" refers to the variable
  394. containing the address to be manipulated. "var2" is the variable where
  395. the result of the manipulation should be placed - it can be the same as
  396. "var1".
  397.  
  398.    extract address    yields the minimum form of the e-mail address
  399.    extract text       yields the personal name field from the address
  400.    extract user       yields the simple user name portion of the address
  401.    extract domain     yields the domain portion of the address
  402.  
  403.  
  404. # lookup "string" <var1> <var2> <var3>
  405.  
  406. Attempt to locate the string "string" in the list variable "var1"; if a
  407. match is found, note the position in the list where the item was matched,
  408. then copy the item at the same ordinal position in the list variable
  409. "var2" into the variable "var3". See above under the description of the
  410. "set" command for more information on list variables. It is an error for
  411. either "var1" or "var2" to be anything other than a list variable. If
  412. "string" cannot be found in "var1", variable "var3" is not changed.
  413.  
  414. Example: list variable "v1" contains "Monday", "Tuesday" and "Wednesday"
  415. list variable "v2" contains "Open", "Closed" and "Open".
  416.  
  417. The command
  418.  
  419.    lookup "Tuesday" v1 v2 v3
  420.  
  421. will result in variable v3 containing the value "Closed".
  422.  
  423. A common form of this command will use the current value of "var1" as the
  424. string parameter, using the command substitution "~vvar1~".
  425.  
  426.