What I am meaning by the reference to a template is to change the script so that it reads and proceses a template instead of reading the subject, body and account from the script setup tab. This does not change the script into a template but rather converts the script so that it can use a template.
To do this you would need to make the following changes:
- Change the external commands so the name of a template could be specified.
- Read the template file from disk
- Count the number of lines in the template
- Loop through each line in the template processing it and replacing any custom variable tags (use the ReplaceCVT command for this).
PS: I would make a copy of the script under another name before I started making any of these changes.
Note, I have attached files to messages using scripts but I have not done this with a template so there may be issues here I have not encountered.