Inside Activate
Workflow and Approval
Send Email from an Approval Step
6 min
this document applies to activate v7 and earlier this document describes how to send an email update directly from an approval step in activate the example demonstrates triggering an email from an approval button, but the same pattern can be adapted for use with a standard form button overview activate supports sending email notifications as part of an approval workflow by attaching a custom form and server side script to an approval step, approvers can manually trigger an email update without leaving the approval context this approach is commonly used to send contextual updates to end users during an approval allow approvers to customise the email subject and body before sending reuse existing service response email templates high level flow the solution is implemented using the following components an approval step with a custom update form a web form containing a send email button a server side script that sends the email and returns the user to the approval approval button configuration the approval step references a custom update form that exposes a send email action the button links to a task wizard that launches the email form \<?xml version="1 0" encoding="utf 16"?> \<webform> \<panel width="100%"> \<controls> \<menubutton text="send email" link="=//job/task/sendupdateemailwizard" imageurl=" /images/add gif" /> \</controls> \</panel> \</webform> email form the email form allows the approver to review and modify the recipient, subject, and message body before sending default values are populated from the requesting user and service response email configuration \<webform> \<panel width="100%" form load="form load" form submit="form submit"> \<controls> \<ribbonpanel> \<controls> \<ribbongroup text="email"> \<controls> \<ribbonbutton link="/" click="onsend" text="send" imageurl=" /images/mail forward32 png" /> \</controls> \</ribbongroup> \</controls> \</ribbonpanel> \<textbox id="txtemail" label="email address" width="800px" text="=/user/emailaddress" /> \<textbox id="txtsubject" label="subject" width="800px" text="=eval(=//job, \\"%=//job/services/instance/0/service/orderfrom/responseemail/subject%\\")" /> \<htmleditor id="txtbody" label="message" width="800px" html="=eval(=//job, \\"%=//job/services/instance/0/service/orderfrom/responseemail/body%\\")" /> \</controls> \</panel> \</webform> server side script the server side script retrieves the form values and sends the email using the built in mail utility after sending, the user is returned to the previous page using system; using innovation activate; using innovation activate utilities; using innovation activate web; using innovation activate web controls; class script webformscript { public void onsend(object sender, menulinkclickeventargs a) { textbox txtemail = (textbox)getcontrol("txtemail"); textbox txtsubject = (textbox)getcontrol("txtsubject"); htmleditor txtbody = (htmleditor)getcontrol("txtbody"); mailutilities sendemail(txtemail text, txtsubject text, txtbody html); webutils gotoreturnpage(); } } notes and considerations the same approach can be adapted for non approval forms by replacing the approval update form with a standard form button ensure smtp configuration is correctly set up in activate for email delivery access to send emails is controlled by the approval context and user permissions