Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
548 views
in Technique[技术] by (71.8m points)

Logic Apps Create HTML Table with multiple lines

I have a working HTTP trigger logic app that sends an email with info provided in the HTTP Post body, the workflow is very simple as shown below.

enter image description here

The HTTP Post body contains a property called Table which contains an HTML formatted table when it's sent the email contains additional characters highlighted in the email screenshot below

A sample of the body content

{ 
"To": "[email protected]",
  "Subject": "emailSubject",
  "Body": "some info",
  "Table": [
    "<table>",
    "<colgroup><col/><col/><col/><col/><col/></colgroup>",
    "<tr><th>Owner Name</th><th>Subscriptions</th><th>Application Names</th><th>Owned Resources Count</th><th>Total Resources Cost</th></tr>",
    "<tr><td>Owner1</td><td>Sub1<BR>Sub2<BR>moehe-devtest</td><td>App1<BR>App2<BR>App3</td><td>count1</td><td>amount1</td></tr>",
    "<tr><td>Owner2</td><td>Sub1<BR>Sub2<BR>Sub3<BR>Sub4<BR>Sub5</td><td>App1<BR>App2<BR>App3<BR>App4<BR>App5<BR>App6<BR>App7<BR>App8</td><td>Counr2</td><td>Amount2</td></tr>",
    "</table>"
  ]
}

The Email Sample with the unwanted characters: enter image description here

I tried to send the Table property in JSON format and use the Create HTML Table Action instead to create the HTML Table but although the unwanted characters disappeared the items in the cells are not displayed in multiple lines so I need help to either remove the unwanted characters from the original flow or to display the items in multiple lines with the Create HTML Table action.

enter image description here

question from:https://stackoverflow.com/questions/66068537/logic-apps-create-html-table-with-multiple-lines

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use replace to eliminate those extra characters, please refer to my logic app.

enter image description here

enter image description here

Expression:

replace(replace(replace(replace(variables('html'),',',''),'[',''),']',''),'"','')

==================update================

This seems to have no border, you may need to specify the border style.

enter image description here

<style>
#testID table, table th, table td {border: 1px solid #F00}
</style>
<div id="testID">
<your-html>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...