Power Platform : Get SharePoint list image in Outlook using Power Automate.

.
“If you tell the truth you don’t have to remember anything.”
.
Hello Everyone,
Greetings for the day.
Hope you all are doing well.
Today in this article I am going to discuss about how to get the image of a SharePoint list item in Outlook using Power Automate flow.
Also we have good number of articles on Power Platform, please have a look.
https://knowledge-junction.in/category/technology-articles/power-platform/
So without getting late, lets get started.
Background
In one of our project requirement is get the SharePoint list item images to Outlook whenever the item was created. So we used Power Automate to trigger the flow when the item created in the list with image and send it in outlook.
Introduction
SharePoint:
Microsoft SharePoint is a cloud-based service that helps organizations share and manage content, knowledge, and applications to:
- Empower teamwork
- Quickly find information
- Seamlessly collaborate across the organization
Power Automate:
Power Automate is a service that helps us create automated workflows between our favorite apps and services to synchronize files, get notifications, collect data, and more.
- Automate business processes
- Send automatic reminders for past due tasks
- Move business data between systems on a schedule
- Connect to more than 500 data sources or any publicly available API
- We can even automate tasks on our local computer like computing data in Excel.
Prerequisites
- Microsoft 365 subscription (requires SharePoint, Power Automate, and Outlook)
- Visual Studio Code (optional)
High Level Steps:
To start we need to create a SharePoint List that includes a column of type “Image”. In this example our SharePoint site is called ‘Forms’ and the list is ‘Image in Outlook’. These names will be referenced throughout the post. The columns for the list have been defined as follows with ‘Image’ being the name of the Image column. Note: SharePoint uses ‘Image’ as the short description for the type, but the display name is ‘Thumbnail’ so these terms will be used interchangeably.

We then create a list entry for Name and Image, that will be used in the Power Automate flow.

At this point we are all set to create our Power Automate flow. We will use an automated cloud flow for demonstration that will send an outlook of the image. The image will be displayed both in a linked and embedded format. The advantage of the linked image is that the outlook size will be smaller, but the recipient must have access to the SharePoint site where it is stored to view it. Embedding allows the image to be viewed by recipients who may not necessarily have access to the SharePoint site as the outlook will contain the image itself.
Detailed Steps:
1. Using Power Automate, create a new automated cloud flow with trigger ‘When an item is created’ and add the SharePoint action ‘Get Item’. Configure the action with the target site address as ‘Forms’ and list as ‘Image in Outlook’ and ID of the list item to get. In this case 1.

Optional, but recommended, is to test as we work through the flow to verify, we are getting the right outputs. In the below example we confirm that we are accessing the latest created list item.

2. Add a new flow action with the SharePoint connector ‘Send an HTTP request to SharePoint’. We will use this action to send an API request to SharePoint for getting just the Image column value of our Image in Outlook item by passing the ID of the list item.

3. Test the flow for ‘Send an HTTP Request to SharePoint’. When the test is complete, copy the content of the outputs body as we will need that later to define our content schema.

4. Add the Data Operation action ‘Parse Json’. For its content, select the body output of the SharePoint ‘Send an HTTP request to SharePoint’.

5. On the Parse Json action, add the Schema by clicking ‘Generate from sample’, and paste the output copied from step 3.


6. Add the Data Operation action ‘Compose’. For its inputs, select ‘Image’ from the Parse Json action.

Test the flow and when complete expand the Compose results to copy the outputs of the Image.

Using Visual Studio Code or a text editor, paste the results to inspect the Image column’s value in detail. Notice it contains a ‘serverUrl’ element to SharePoint and a ‘serverRelativeUrl’ element to the image we added to the list item. This tells us that when we added the image to the list item, SharePoint, stored it as a file in its SiteAssets folder for the SharePoint Site, Forms, under a Lists subfolder with the list’s internally unique identifier. It is these two (2) elements we are after to get the image.

7. Delete the ‘Compose’ action created in step 6. We only needed it to capture a sample of the data that we will use next.
8. Add another Data Operation action ‘Parse Json’. For its inputs, select ‘Image’ from the prior Parse Json action (same as Compose in step 6).

9. On the Parse Json action, add the Schema by clicking ‘Generate from sample’, and paste the output copied from step 6.


10. Add a new flow action with the SharePoint connector ‘Get file content’. We will use this action to get the content of the image file. Enter the Site Address to the SharePoint site, Forms in this example. For the file identifier, we use the ‘serverRelativeUrl’ property from the Parse Json result, but we need do a couple of expressions to transform the data:
a) Using the ‘replace’ function we remove the redundant site information – /sites/Forms
b) Using the ‘encodeUriComponent’ function we Url encode the remaining string
The resulting expression should look like the following:
encodeUriComponent(replace(body('Parse_JSON')?['serverRelativeUrl'],'/sites/Forms',''))

11. Add a new flow action with the Data Operation connector ‘Compose’. We will use this action to compose an HTML structure of the outlook body to use for sending the embedded and linked image. For the embedded image we use the body output of the Get File Content action, but we must base64 encode it with an expression like the following:
base64(outputs('Get_file_content')?['body'])
For linking we concatenate the ‘serverUrl’ and ‘serverRelativeUrl’ obtained from the second Parse Json action in step 8.

12. Add a new flow action with the Office 365 Outlook connector ‘Send an email (V2)’. Add the recipient and in the subject, we add the Title field of the get item from step 1. For the body we use outputs from the compose action in step 11.

We have reached the end of the flow and can now test to see if it shows up in our mailbox.

.
Hope this article will help us to get the SharePoint list image in outlook using Power Automate.
Also get my article updates on my social media handles.
LinkedIn – https://www.linkedin.com/in/khasim-shaik-8784a1232/
Twitter – https://twitter.com/KhasimShaik2009
Facebook – https://www.facebook.com/profile.php?id=100078255554660
Thank you for your support, will catch up with new article soon.
Keep learning and keep smiling.
Have a great day.
Thanks.
You must log in to post a comment.