web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Multi-line variable in...
Power Automate
Unanswered

Multi-line variable inserted into email as single line

(0) ShareShare
ReportReport
Posted on by 12

Hello community,

 

I have a simple PAD flow that will run a PS script and output the results to a variable.  The variable appears to have multiple lines as it should:

ericmabkv_0-1714422012857.png

I then insert the variable into an email.  When the email is sent, the contents of the variable appear as a single line only.

ericmabkv_1-1714422067140.png

How can I get the variable to appear in multiple lines in the email?

 

Thanks,

Eric

 

I have the same question (0)
  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Try a split text by NewLine.

    MichaelAnnis_0-1714429238090.png

    Then try to rejoin it with JoinText...should look more like this:

    MichaelAnnis_1-1714429288139.png

    Try putting JoinedText into the email and see if that works.

    If it doesn't...let us know, we will look further into it.

    Do you have access to change the python output?  If so, we may look into changing that code to do a new line character like <NL> or <br>, something that we can find with split text and replace rather than having the output show up like it is.

    Good luck!

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @ericmabkv ,

     

    You can also try this in this way.Please find the solution.

     

    VishnuReddy1997_2-1714451781743.png

     

     

    VishnuReddy1997_1-1714451559927.png

     

    Code: 

    Please copy the below code into your flow.

    SET PowershellOutput TO $'''The user: Eric Test2 is not in Insperity
    The user: Eric Test is not in Insperity'''
    Variables.CreateNewList List=> Output_List
    Variables.AddItemToList Item: PowershellOutput List: Output_List
    Outlook.Launch Instance=> OutlookInstance
    Outlook.SendEmailThroughOutlook.SendEmail Instance: OutlookInstance Account: $'''Varikutivishnuvardhan.reddy@acme.com''' SendTo: $'''Varikutivishnuvardhan.reddy@acme.com''' Subject: $'''Sample''' Body: Output_List IsBodyHtml: False IsDraft: False

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

     

  • ericmabkv Profile Picture
    12 on at

    This almost worked.  I had to use "." as a delimiter and I can see that the output was added to separate lines in the TextList, however when emailed it still appeared on one line.

    ericmabkv_1-1714488156096.png

     

    ericmabkv_0-1714488141135.png

     

    ericmabkv_2-1714488191466.png

     

     

  • ericmabkv Profile Picture
    12 on at

    This option also did not work. I also tried splitting text then adding to list but all list formatting is lost when inserted into the email body.

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @ericmabkv 

     

    Could you please share screenshot of your full flow screenshot and outlook send email screenshot like below?

    Deenuji_0-1714583740088.png

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    I really thought that was going to work.  Here is my Custom GPTs recommendation, but I haven't tested this:

     

    To ensure that the variable's content maintains its multi-line format in an email when using Power Automate Desktop, you need to ensure that the email body is set to accept HTML formatting. This will allow you to use HTML tags to format the text, including line breaks. Here's a step-by-step process to modify your Power Automate Desktop flow:

    1. Convert Newlines to HTML Breaks: Before sending the email, replace newline characters in your PowerShell script output with <br> HTML tags. This can be done using the Text.Replace action. The newline character is typically represented as \r\n (carriage return and newline).

       

      Text.Replace Text: %PowershellOutput% TextToFind: "\r\n" ReplaceWith: "<br>" Result=> FormattedOutput

       

       
      1. Send Email: When configuring the Email.SendEmail action to send the email, ensure you set the IsBodyHtml property to True. This will tell the email client that the body of the email is HTML and should render as such.

         

        Email.SendEmail.Send SMTPServer: "your.smtp.server" Port: 25 EnableSSL: True SendFrom: "your-email@example.com" SendTo: "recipient@example.com" Subject: "Your Subject Here" Body: %FormattedOutput% IsBodyHtml: True

         

        By setting IsBodyHtml to True and replacing newline characters with <br>, the email client will interpret the line breaks correctly, preserving the multi-line format of your variable's content in the sent email.

         

         

         

        It basically replaces the text with the HTML tab <br>.

        Good luck!

         

         

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @ericmabkv 

     

    Follow the steps outlined below if the text appears in a single line.

     

    After splitting your PowerShell script, you will obtain your texts in list variables as shown below.

     

    Then, create a variable named `strhtmlbody` with an empty value. Next,

     

    Iterate through your `TextList3` variable and concatenate each list value with "<br/>" as illustrated in the screenshot below.

     

    Finally, pass the same variable into the email body and enable the "Body is HTML" option as depicted in the second screenshot.

     

    Deenuji_0-1714621183534.png

    Deenuji_1-1714621469447.png

     

     

    Code:

    SET PowershellOutput TO $'''The user: Eric Test2 is not in Insperity
    The user: Eric Test is not in Insperity'''
    Text.SplitText.Split Text: PowershellOutput StandardDelimiter: Text.StandardDelimiter.NewLine DelimiterTimes: 1 Result=> TextList3
    Outlook.Launch Instance=> OutlookInstance
    SET Strhtmlbody TO $'''%''%'''
    LOOP FOREACH CurrentItem IN TextList3
     SET Strhtmlbody TO $'''%Strhtmlbody% %CurrentItem% <br/>'''
    END
    Outlook.SendEmailThroughOutlook.SendEmail Instance: OutlookInstance Account: $'''deenu@office365journey.onmicrosoft.com''' SendTo: $'''deenucse@gmail.com''' Subject: $'''Sample''' Body: Strhtmlbody IsBodyHtml: True IsDraft: False

     

    How to copy/paste the above code into your PAD?

    Deenuji_2-1714621546950.gif

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

     

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @ericmabkv ,

     

    I have not splitted the text. I have just created the list and added the variable to the list.

    Just once go through my previous post.It working fine for me.

     

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

  • ericmabkv Profile Picture
    12 on at

    I have already attempted to replace \r\n with \br but that did not work either.  The preview of the output variable appeared correct but it did not retain the formatting when inserted into an email.  The email Body Is HTML is enabled as well.

     

    ericmabkv_0-1714673286529.png

     

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @ericmabkv 
    Have you tried my above suggestion?

     

    if it’s not working, then please share the screenshot of your full flow(hide all sensitive data). I will assess your flow and assist you further.


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 245

#2
David_MA Profile Picture

David_MA 216 Super User 2026 Season 1

#3
Valantis Profile Picture

Valantis 212

Last 30 days Overall leaderboard