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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / html to text function ...
Power Automate
Unanswered

html to text function adding random break lines issue

(0) ShareShare
ReportReport
Posted on by

I am extracting email body then adding the data in a new raw in excel file, using the html to text first, then substring function to extract the needed data.
the issue is that the html to text function is inserting random break lines in the converted texts, the thing that is causing errors in substring function.
does anyone knows why and how the break lines are inserted in html to text function ? and how can i handle it ?

thanks,

 

Capture1.PNGCapture2.PNG

Categories:
I have the same question (0)
  • v-yamao-msft Profile Picture
    on at

    Hi @Anonymous ,

     

    What’s the error message you’ve got on your side?

     

    Could you share more details on the functions?

     

    What’ the format of the email body?

     

    You mentioned that Html to text action adding random break lines, how is it displayed?

     

    According to your description, I guess that you want to extract contents from the email body. I have made the following test for your reference.

     

    The email is formatted likes below:

    1.PNG

     

    Trigger the flow by When a new email arrives, then the action Html to text.

     

    To get Name, use the following code:

    substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Name'),5),sub(indexOf(body('Html_to_text'),'Date'),add(indexOf(body('Html_to_text'),'Name'),5)))

     

    Using the following statement to get the Date:

    substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Date'),5),sub(indexOf(body('Html_to_text'),'Comments'),add(indexOf(body('Html_to_text'),'Date'),5)))

     

    The similar configuration for the Comments:

    substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Comments'),9),sub(length(body('Html_to_text')),add(indexOf(body('Html_to_text'),'Comments'),9)))

     

    Images for your reference:

    2.PNG3.PNG

     

    Best regards,

    Mabel

     

  • Community Power Platform Member Profile Picture
    on at

    thanks for your replay @v-yamao-msft , here are the answers to them:

     

    - the error: Unable to process template language expressions in action 'Add_a_row_into_a_table' inputs at line '1' and column '2529': 'The template language function 'substring' parameters are out of range: 'start index' and 'length' must be non-negative integers and their sum must be no larger than the length of the string. 

    - the function : similar to the context you shared.

    - did not get your question about the email format: it is an outlook email, can you clarifu what details you need. 

    - the break lines instered as the follwoing sample: in the original email, break lines are never like this, and they are changing randomly.  

     

    Lead Contact: test test Organization: gefh Address: dsbsgb vsdvs dfvdf, dvdf
    dfvfd United States Phone Number: (235) 457-4736 Email: vc@dfb.com Program/Event
    Name: gedgvd Program/Event Timeframe: dvfvbzs Website:
    https://clicktime.symantec.com/3PuPQyfz13i5NMBmC5D9vvJ7Vc?u=http%3A%2F%2Fdfg.com
    Donation Type Request: Funding Dollar Amount: 1423 Does your organization
    benefit Blue Diamond's neighborhoods?: Sacramento, CA Focus Areas: Agricultural
    Education Health & Wellness Community Development Briefly describe your
    organization and its mission. How is it administered?: dgbbrth Please attach a
    copy of your most recent annual report.:

     

    hope i could make the issue clearer.

     

     

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    I found a solution:

    convert the output of the html to text function to array using creatarray(), then converting it back to string using string(), and then removed the /n (break lines) from it using replace(), in this way substing() is not throwing errors.

    hope this would be helpfull.

     

  • Bluehornet Profile Picture
    4 on at

    I'm having this same issue, but it seems to me that HTML to Text is not adding the \n, its randomly adding a line break, and the then Parse JSON adds the \n for the line break.  How do I remove the \n from the Parse JSON outputs?  I can't use replace() as it expects a string and not an object from the Parse JSON.

    JSON Input from html to text (notice line breaks)

    {"Type_of_Request":"Name

    Change","Rate":"$250.00","Date_Submitted":"2019-04-23 -

    10-45-18-am",

     

    JSON Output

    "Type_of_Request": "Name\nChange",
    "Rate": "$250.00",
    "Date_Submitted": "2019-04-23 -\n10-45-18-am",

     

     

     

  • Bluehornet Profile Picture
    4 on at

    I was having this same issue where as I have a flow that accepts an email w/JSON formated data in HTML, performs html to text, then Parse JSON.  Nothing seemed to work for me to get the line breaks and subsequent \n out of my data.  The only thing that worked is inserting a <br> after each JSON data set within my code (php mailer) that generates the email.  The <br>'s then get stripped out by the html to text and no more random line breaks or \n.

     

    $message = '{';
    $message .= '"Type_of_Request":"'.$requestType. '",<br>';
    $message .= '"Rate":"'.$rate. '",<br>';
    $message .= '"Date_Submitted":"'.$datestamp. '",<br>';
    $message .= '"First_Name":"'.$firstName. '",<br>';
    $message .= '"Last_Name":"'.$lastName. '",<br>';
    $message .= '"Email":"'.$userEmail. '"';
    $message = '}';

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard