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

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.

SharePoint list columns
fig: SharePoint list columns

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

SharePoint list item
fig: SharePoint list item

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.

Power Automate : Get item action
fig: Power Automate : Get item action

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.

Power Automate :Get item action output
fig: Power Automate :Get item action output

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.

Power Automate : Send an HTTP request to SharePoint action
fig: Power Automate : Send an HTTP request to SharePoint action

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.

Power Automate : Send an HTTP request to SharePoint action output
fig: Power Automate : Send an HTTP request to SharePoint action output

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

Power Automate : Parse JSON action for Image ColumnValue
fig: Power Automate : Parse JSON action for Image ColumnValue

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

Power Automate : Insert sample JSON for Image ColumnValue
fig: Power Automate : Insert sample JSON for Image ColumnValue
Power Automate : Parse JSON - Image ColumnValue Schema
fig: Power Automate : Parse JSON – Image ColumnValue Schema

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

Power Automate : Compose action
fig: Power Automate : Compose action

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

Power Automate : Compose action output
fig: Power Automate : Compose action output

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.

Result of compose action in Notepad
fig: Result of compose action in Notepad

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).

Power Automate : Parse JSON action
fig: Power Automate : Parse JSON action

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

fig: Power Automate : Insert sample JSON
fig: Power Automate : Insert sample JSON
Power Automate : Parse JSON Schema
fig: Power Automate : Parse JSON Schema

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',''))

Power Automate : Get file content action
fig: Power Automate : Get file content action

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.

Power Automate : Compose action for image
fig: Power Automate : Compose action for image

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.

Power Automate : Send an email action
fig: Power Automate : Send an email action

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

SharePoint list image in Outlook
fig: SharePoint list image in Outlook

.

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.

Khasim Shaik

SharePoint & Power Platform Developer at OS InfoTech

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: