Introduction
In this article, we will see how we can read the files' file properties in a SharePoint Online document library folder and send these properties in tabular format with custom CSS styling in the email notification.
Create a JSON button to send a notification
In the SharePoint library, add a SharePoint field 'Send Notification' of type Single line of text.
![Power Automate- Send Notification With File Properties Table]()
Use the option 'Format this column' for the SharePoint field 'Send Notification' to apply JSON formatting to create a button for triggering flow. Use below JSON code.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"<flow GUID>\"}"
},
"attributes": {
"class": "ms-fontColor-themePrimary ms-bgColor-themeDark--hover ms-fontColor-themeLighter--hover .ms-ContextualMenubutton"
},
"style": {
"cursor": "pointer",
"display": "=if([$PermMask]>='0xb00', 'none', '')"
},
"children": [{
"elmType": "span",
"attributes": {
"iconName": "MicrosoftFlowLogo",
"class": "ms-font-xxl"
},
"style": {
"padding-right": "6px"
}
}, {
"elmType": "span",
"txtContent": "Send Notification"
}]
}
This will add the following button to the SharePoint field.
![Power Automate- Send Notification With File Properties Table]()
When you click this button at the folder level, it will run a flow that will get all the properties of all the documents in that folder, apply some styling and send it in an email as a table.
Flow for sending notification
Use SharePoint trigger For a selected item
![Power Automate- Send Notification With File Properties Table]()
Initialize a string variable varTableStyle to set the table's styling inside the notification's email body.
![Power Automate- Send Notification With File Properties Table]()
Below is the value of this string variable for CSS styling. You can use your own CSS styling.
<style>
table {
border: 1 px solid #b3adad;
border - collapse: collapse;
padding: 5 px;
}
table th {
border: 1 px solid #b3adad;
padding: 5 px;
background: #f0f0f0;
color: #313030;
}
table td {
border:1px solid # b3adad;
text - align: left;
padding: 5 px;
background: #ffffff;
color: #313030;
}
</style>
Get all files properties inside the SharePoint folder
Use the SharePoint action Get files (properties only) to get properties of all files inside a folder. You have to select your site, document library, and folder name.
![Power Automate- Send Notification With File Properties Table]()
Create an array of files properties
What does Select Action do? Use Select action. Select the specified properties from all elements of the 'From' array into a new one.
Our previous action gives us an array of all document properties in a given folder. Using the Select action, we are creating another array of custom properties for documents we want to show in our email notification.
![Power Automate- Send Notification With File Properties Table]()
Next, we will use Create HTML table action to create html table from this array. This action uses the output of the previous action to create html table.
![Power Automate- Send Notification With File Properties Table]()
Finally, use Send an email (V2) action to send an email with a formatted html table having document properties. Use varStyleTable for styling and output of Create HTML table action for document properties data.
![Power Automate- Send Notification With File Properties Table]()
The table in the email notification will look like the one below. It has all the CSS styles applied to html table.
![Power Automate- Send Notification With File Properties Table]()
Summary
In this article, I discussed how to create a custom flow to send an email notification with formatted data in the form of html table. We use custom CSS inside flow to format the html table inside the email body. We are using SharePoint trigger; for a selected item to trigger this flow, click the JSON button created in the SharePoint library field.
Some known limitation of this flow is that you can use it only if you are part of the Owners group in SharePoint. Another limitation is that this flow will trigger only when you create it in the Default Power Platform environment. In other custom environments, this will not work. I hope Microsoft will soon come up with a solution for these limitations.