Power Automate offers a range of capabilities to automate business processes, including the ability to extract data from SharePoint lists and send it via email. In this tutorial, we will leverage Power Automate to retrieve comments associated with a particular SharePoint list item and send them to an email recipient.

We will email the comments using a clean, professional-looking HTML table sent via Outlook:

How to Get a Single List Item’s Comments
By using the “Send an HTTP request to SharePoint” connector, it’s possible to retrieve comments associated with an item from a SharePoint list. We will need to extract just the comments data using an expression in a “Compose” action, and then use a “Select” action to choose the fields we want to include in the table, such as the comment author, date, and content. Lastly, we will use the “Create HTML Table” action to format the selected data into an HTML table before sending the comments to an email recipient.
1. Manual Trigger
In the flow that we will build, we will use a manual trigger.

2. The “Send an HTTP request to SharePoint”
Next, add a “Send an HTTP request to SharePoint” connector which we will configure below to retrieve the comments for a selected item from the SharePoint list.

In the above example, I have selected the SharePoint site named “DemoSite” and the “Acronyms” list has been chosen. The comments related to item ID 66 will be retrieved, and the required properties for the Headers have also been specified.
Method:
GET
Uri:
_api/web/lists/getbytitle('<list name>')/items(<item-ID>)/Comments
Headers:
accept:
application/json;odata=verbose
content-type:
application/json;odata=verbose
Make sure to enter the List name and list item ID into “Uri property” of the “Send an HTTP request to SharePoint” action as shown below:

3. Extract the Comments from the “Send an HTTP Request to SharePoint” Action
Next we will extract the comments from the resulting output of the “Send an HTTP request to SharePoint” action using an expression in a “Compose” action:

The expression used in the Compose action is:
outputs('Send_an_HTTP_request_to_SharePoint')?['body']['d']['results']
The Expression: How it works
The reply or response from the “Send an HTTP request to SharePoint” is called the response object. The response object contains the “status code”, “headers” and a “body”. And buried within the body section of the response object we will find the list item comments.
Below we see an example of a response body. The list item comments are actually found in the body within an array called “results”:

We can extract the comments from the response object using the following expression:

If we examine the array results array, we see that it does indeed contain the three list item comments. If no comments were found then the results array would be empty.

4. Use a Select Action
In step 4 we use the “Select” action to choose the fields we want to include in the HTML table, such as the comment author, date, and the comment text:

Enter the following expressions in to the Select action:
Name:
item()?['author']['name']
Date:
formatdateTime(item()?['createdDate'], 'dd MMM yy')
Text:
item()?['text']
In the image below we see the properties that are selected for each comment:

The Select action produces the following output:

5. Create the HTML Table
We use the “Create HTML Table” action to format the selected data into an HTML table before sending the comments to an email recipient. The output of the Select action is used to create the HTML table:

6. Add some HTML table formatting style code
This is the table formatting style code I used. I have provided the code below which you can copy-and-paste into your flow.

Here is the code that you can copy-and-paste for the Compose Table Formatting Style action:
<style>
table {
border: 1px solid #1C6EA4;
background-color: #EEEEEE;
width: 100%;
text-align: left;
border-collapse: collapse;
table-layout: auto;
}
table td, table th {
border: 1px solid #AAAAAA;
padding: 10px;
}
table tbody td {
font-size: 13px;
}
table thead {
background: #1C6EA4;
border-bottom: 2px solid #444444;
}
table thead th {
font-size: 15px;
font-weight: bold;
text-align: left;
color: #FFFFFF;
border-left: 2px solid #D0E4F5;
}
table thead th:first-child {
border-left: none;
}
</style>
7. Send the Comments using Email
This is the Send an email action that will email the nicely formatted HTML table. Pay close attention to the order of the Compose outputs in the email body or your HTML table styling wont be applied:

And finally, we see the email that was sent out:

Leave a Reply