top of page

Give me a break!

  • Edward
  • Aug 17, 2023
  • 2 min read

In Power Automate we often want to use a variable to include in an email response to a user. It gives loads of flexibility in customising the response based on a condition, for example. A classic query (and, on occasion, annoyance!) with this approach is adding line breaks in between each line, as you'd want to do for a properly formatted email. Quick tips like this can drastically improve the user experience.


Use Case


I've been working on a solution for students that are signing up to a Study Abroad programme and as part of their application, they can let us know about any special circumstances that should be considered when their placements are being arranged. My users in the academic department don't want an email for every application received, but they do want a notification when the student has included special circumstance details - a great opportunity to use a Condition in Power Automate and use a variable to gather together the data the student has provided. However, getting it formatted is key so my users don't waste time scanning through data that is poorly presented. Let's take a look at the resolution.


Favourite Colour Example


In the example below, we will ask the user what their favourite colour is. I've set up a simple condition where Power Automate will inspect an input (from a manually triggered flow) to see if it equals 'Red'. If it does, we will send the user a Wikipedia article about the colour red, and if not, let's send them a general email about colours.


Be sure to click/tap the images in the article to expand them which should make it much easier to view.


I've set out my Flow and it looks good, and I've added line spaces in to the variables as I want the output to appear to the user in the resulting email. I've highlighted the line breaks using red squares in the below screenshot (well, we're talking about the colour red, so I figured we should continue the theme!).



ree
Flow configuration with Condition and variables, showing the intended line breaks

I ran a test of my Flow; the Flow ran successfully and the output of the variable in the Flow run looks good. The line breaks appear in between the text as expected, as indicated by the red arrows in the below screenshot.



ree
Flow run test showing the intended line breaks in the variable output

But when my user receives the email, this is what they see - no line breaks!



ree
E mail received with no line breaks


We can resolve this by using HTML tags within our variable.


The <br> tag means "break" (or "line break") and we can add it within the variable whenever we want a line break to appear.

Here's how I've updated the variable to include the <br> tag. Note that I've added one <br> tag at the end of a line to start a new line, and then when I want a completely blank line, another <br> tag to start the next line again - such as at the end of the line "Thanks for reading this message".



ree
Variable updated with <br> tags to add a new line





Let's try sending the email again. Here's what the user sees now:



ree
E Mail correctly formatted with desired line breaks


Much better!


There are many other simple and useful HTML tags we can add in - perhaps some future topics for a future article. Let me know if you have any requests on these, want to know or share use cases, or any other comments or questions.

 
 
 

Comments


© 2023

Thanks for submitting!

bottom of page