03 Oct Microsoft Flow: Reusable Email Content
Overview: Microsoft Flow has a lot of capabilities for automating processes using triggers, actions, and conditions. While working on a project with a variety of emails to different users in the organization, there was a need to standardize the emails without having to re-produce branding manually in all these emails. This solution stores all branding elements in a SharePoint list, which is then re-used in all the emails. The goal is to be able to update the SharePoint list and all changes will be reflected in all the Flow emails.
Flow Scenario: This is an Event Request approval process that needs approval from a Manager first. Once the Manager approves the request, the Director receives an email to Approve or Reject the request. The initiator then receives the final email that states if the request has been approved or rejected.
Video Explanation
Plan Your Process Structure and Email Message Structure
It’s important to map out the business process with flow diagrams to help keep track of which Flows need to be created and thoroughly capture all business logic. Mapping out the strategy first helps to understand what needs to be built as a visual reference.
Mapping out what is required in the emails and consistently used across emails is important in the beginning as well. Advanced expressions can be used to display information in the email only if there is a value.
Create a SharePoint list
Create a Custom List called Event Request. This holds the Event details along with Manager and Director approvals.
Create another Custom List app called “Branding”. This list holds all the HTML/CSS Branding elements that will be used in the emails.
Columns used:
- The MessageOpening and MessageClosing <div> tags will be the container for the message.
- ApprovalLink contains a URL to my Dashboard. If the link changes in the list, all Flows are always pointing to the correct link.
- ManagerApprovedEvent and DirectorApprovedEvent will have green text for the event request status as being approved.
- ManagerRejectedEvent and DirectorRejectedEvent will have red text for the event request status as being rejected.
- Banner will have a background color and some additional formatting to the text.
Create Your Flow
Add a trigger for the EventRequest and an Action to get the Branding list. These examples use the “When item is created (and/or modified)”, however, the Recurrence trigger can be used as well.
Using the Outlook Send an Email Action, add the SharePoint columns to the Message Body. All of the SharePoint columns from the Branding list are in the Get item section.
Be sure to select “Show Advanced options” and Select Is HTML “Yes”.
Use Expressions to Conditionally show content in the email only when the Manager or Director has added a comment. Otherwise, don’t include the information in the email.
Example formula will append the comment after the “Manager Approval Decision” text:
if(equals(triggerBody()?[‘ManagerDecision’], null), ”, concat(‘<strong>Manager Approval Decision:</strong> ‘, triggerBody()?[‘ManagerDecision’]))
Test the Flow
Label and rename the Actions, Conditions, Switches to make the Flows more readable.
Labeling the Subject line with “who” the email should be sent to is helpful with testing to ensure that the Flows are sending emails to the appropriate users.
Final Product
Initial Email with Approval Link Sent to Manager
Once Manager Approves, Director Receives Notification of Status and Approval Link
The Initiator Receives the Final Email with Comments
Video Explanation