Email Sending in Alfresco Workflows

Alfresco has support for inbound and outbound emails, because of this we can enhance the interaction of system with all involved participants. For instance we are maintaining one workflow related to contract management in alfresco so it is very desirable that during any updates in contract status (approved, rejected, lapse etc…) concerned person has to be informed promptly. Email is the best medium for that by utilizing outbound email capabilities of Alfresco we can send email to all related actors in workflow.

Send simple notification mail

Code for Sending simple email within workflow is as follow

if (wf_notifyMe)


   var mail = actions.create("mail"); =;

   mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;

   mail.parameters.from =;

   mail.parameters.text = "It's done";



This snippet is from out of box adhoc workflow process definition file. So, if you want to send normal email during particular transition in your workflow you need to put above code in your workflow process definition file within that transition tag. Check out adhoc process denition file in your alfresco setup to get more details on how it is included in process definition file.

Sending Email using template

If we want to go one step further and want to send email within particular format with more details so that it appears more users friendly and informative in that case we can use email templates. These email templates are widely used in real life scenarios, we often got system generated promotional email from various companies, email during registration to some sites, notification emails from mobile subscribers all of them are nothing but templates because it save lot of human effort.

Here is how you can send email with template within alfresco workflow.

<transition name="closecase" to="caseclosed" >
  <action name="sendNotification" class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> 
	var mail = actions.create("mail"); = "";
        mail.parameters.template =companyhome.childByNamePath("Data Dictionary/Email Templates/wf-email.html.ftl");
        var templateArgs = new Array();
        templateArgs['workflowTitle'] = "workflowTitle";
       var templateModel = new Array();
      templateModel['args'] = templateArgs;
    mail.parameters.template_model = templateModel;  			
    mail.parameters.subject = "!!! Important Notification !!!";
    mail.parameters.from = "";

We need to pass array of values for all variables used in the workflow template so that it can generate final output.

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight


I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *