Sending e-mails via JavaScript API
We have seen how easily we can send e-mails from the Alfresco web client interface. However, it is often necessary to send e-mails from your scripts and applications as well. Alfresco JavaScript API is fully capable of sending e-mails.
From the web client, we have sent e-mails using the Run Action method. In the JavaScript API also, e-mails can be sent by the actions execution only.
In this recipe, we will create a script that would send mail to a particular user, use a template to construct the e-mail message body, and finally invoke the script through a rule.
How to do it...
1. Open Alfresco web client and navigate to Data Dictionary | E-mail Templates space. This is the space where, by default all templates related to e-mails are stored.
Note
Though it is not mandatory to have your e-mail templates in this space, conventionally the templates for e-mails are stored here.
2. Create a new template with a name send-e-mail.ftl, using the following code:
Dear ${args...