If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Creating a Script Part

To create a part that is defined by a VB.NET script, follow the basic steps in Creating a Message Part and follow the additional steps:

  1. On the General tab, leave the Base Part field blank and leave the Only Derived box unchecked.
  2. Select Script from the Type drop-down list.
  3. Enter the script to define the contents of the Message Part on the HTML and/or Text tabs.
    • If the Message System supports HTML, then enter the appropriate text on the HTML tab and optionally on the Text tab (if you want to support a fall-back option to a plain text message for recipients whose email program does not support HTML). If the Message System does not support HTML, specify the appropriate text on the Text tab.
    • See the Data Table message part, which is included with the standard Aptify installation, for a sample script.
    • Use the Scripting icons to assist you with writing the script. See Administering Scripts for more information.
    • See Scripting Response Object for information on the intrinsic Response object, which is available for Messaging scripts.
       
  4. Aptify's Messaging Engine supports the ability to pass in record data to a message's HTML code using Aptify's mark-up convention (the <<Field Name>> format).
  5. In addition, the Messaging Engine can use C formatting tag to display numeric fields with a currency symbol and a d tag to display date/time fields in the date only (short date) format. For example, you can format money fields with its proper currency symbol using this convention: <<Money Field:C>>Other formatting options appear below. Note that a value after a format character specifies the number of significant digits or decimal places to display. (For example, the format string, <<Number Field:F2>>, displays a fixed-point number with two decimal places.)
    • C: Displays numeric values in currency format.
    • D: Displays numeric values in decimal format.
    • E: Displays numeric values in scientific (exponential) format.
    • F: Displays numeric values in fixed format.
    • G: Displays numeric values in general format.
    • N: Displays numeric values in number format.
    • X: Displays numeric values in hexadecimal format. This is case sensitive. The hexadecimal characters are displayed in the case specified.

      For more information about other formatting types, including dates, please visit Microsoft's page on Formatting types in .NET.

  6. See About the Order Confirmation Message Template for Dot Net Mail for information on the sample Message Template that illustrates these features. 

    Sample Script Syntax 

Scripting Response Object

Each message part has the ability to execute its own script. In that script, the part can act on an intrinsic object called Response. The Response Object exposes the following members:

  • WriteText (ByVal NewText As String): Sends new text to the Internal Buffer of the response object.
  • GetText as string: Returns all text in the Internal Buffer of the response object.
  • Clear: Removes all text from the Internal Buffer of the response object.
  • MarkupString(ByVal S As String) as string: Replaces tag items with actual values located in the place of the tags. A tag is considered to be the name of a field. It should have a format such as <%fieldname%>, where fieldname is the name of a database field.
  • ExecutePart(ByVal PartID As Long): Accepts the ID of another Message Part and attempts to execute it. The resulting text for that execution is buffered at the current end of the Internal buffer of the Response Object. Note that recursive parts are prohibited. If the ExecutePart command results in a recursive call, an error message appears in the Messaging Preview window, which states that recursive parts are not allowed.

    See the Data Table Message Parts record included with Aptify for one example of how to use the Response object.

Copyright © 2014-2017 Aptify - Confidential and Proprietary