- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it possible to execute the template in Module
Hello All,
I want to send the email to the user. I have created format template (Email Template) in the First script Client. Now I want to send the mail in Module, So I have used JavaMail API for the email sending purpose. Is it possible to run the format template from Module and get the generated HTML content ??
Thank You,
Vasanth
- Labels:
-
Developers
-
Knowledgebase
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suggest you use a script instead of a format template. Then you set the script type to "template" and put
#!firstspirit
in the first line of the source.
Here is a complete example:
#!firstspirit
$CMS_VALUE(a) + $CMS_VALUE(a)$ = $CMS_VALUE(a + a)$
Then your code should look like this:
TemplateSet ts = ....;
Script script = ....;
Map<String, Object> params = new HashMap<String, Object>();
params.put("a", 21);
String result = script.getExecutable(ts).execute(params).toString();
With the above code "result" should then contain "21 + 21 = 42".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Peter,
Thank you for your reply.
But in my case the scenario is different Peter. For example, i have to include the image from the Media store so i have to use the CMS_REF tag. So i need to execute format template and get the resultant HTML code alone. I have already checked the API but i couldn't find it. Please let me know is there any way to do this.
Thank You,
Vasanth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm afraid that this is not possible. Of course you could call your format template via $CMS_RENDER in the solution sketched above, but this will not work because you cannot provide the correct context.
I suggest that you create a schedule entry where 1st) a "one page generation" task is performed and 2nd) the generated html file is sent as mail body from a script task.
You could execute this schedule entry from your script, providing parameters like receiver etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Peter.

