Fixed: Outlook desktop unable to render SharePoint hosted images embedded in to mail body through PowerAutomate send email action

This post comes out from a recent support experience to one of my clients. He was trying to use Microsoft PowerAutomate flow to embed a SharePoint library hosted image in to an email notification which sent regularly across the organization for all users. Usual way for doing this is using the <img src tag in the send email action but interestingly, these behaviors was a showstopper until I figured out the solution after several hours (described at the end of the article).

111

Behaviors:

  1. Embedded images from a SharePoint URL did not render in Outlook desktop App
  2. Same image renders in OWA (Outlook Web App) however, there was a slight delay in loading the image.
  3. Same image hosted in public hosting locations rendered nicely as well (e.g – https://www.w3schools.com/, Google etc..)

SharePoint hosted image in Outlook Desktop App: Strange enough !

3

External hosted image in Outlook Desktop App:

4

Tried and did not work for my case:

  • Change the text format to HTMLOutlook client application (File -> Options -> Mail -> Compose message in HTML format). This was already in place for my scenario.
  • Add the domain to safe/trusted sites in the browser settings
  • Plethora of other solutions from Microsoft articles and forums

clip_image002[6]

The real solution:

To overcome this issue, you simply have to use these additional lines in your email step. Add a compose action and point it to ‘Get file content using path’ SharePoint action (or you can directly add this line to the mail body HTML)

Add a new Compose action in to the PowerAutomate flow 

Set the Expression as below (you can copy and paste this)

dataUri(outputs('Get_file_content_using_path')?['body'])

67

Amend the Mailbody to reflect the following or add the above mentioned expression directly to the HTML body. Either way should work.

<p><br>
File content using path<br> 

<img src="@{outputs('Compose_2')}"></img>
</p>

8

Full flow: Tested and working perfectly across web client and desktop client of Outlook

9

Result: SharePoint hosted image is now rendered perfectly in Outlook desktop App.

10

Root cause analysis:

The key point is the use of dataUri() to convert the file content to the right format that HTML can understand. An image or a file in general from a SharePoint link is not public link. Only authenticated users can view the image which is the root cause of this issue.

If a user logs in into Outlook on the web from  a browser, their Microsoft identification data are stored locally within the browser context as cookies. As a result, when opening an email that contains a SharePoint link in HTML image tags, a request will be sent to SharePoint servers with the same identification and the image can be downloaded if the user has enough privilege.

It’s the same way that if you have already logged in into one of the google services, you won’t have to login again when accessing other Google services in deferent tabs.

On the other hand, Outlook client is simply an email application which does not share the same architecture as a browser. Outlook account credentials are stored differently and Outlook does not have mechanism to detect and pass credentials to other Microsoft services. Hence, when it sees a SharePoint link in HTML image tags, a request without any authorization data will be sent to the SharePoint servers and of course, it will be refused. If a hyperlink added to the email, clicking on the link will open a browser and you will need to sign in.  In the end, the main purpose of Outlook client is for email-related tasks and it will not handle authentication for other services.

Advertisement

Add a button in to a SharePoint List/Library to trigger a Flow (part 02-customization)

Part 02 (This article)

In my previous article, we saw how we can add a button in to SharePoint online list or library to trigger a flow in place. We are continuing with this article on how we can customize the newly added button to change its appearance (Well, let’s make it look like a button).

bc368f944e446068509494a3123d91d7

Changing the appearance:

Go to the format mode from the target button column. And we can use the following parameters to change the look and feel. My button here looks good as it stands out from the rest of the content in this space.

  • txtContent: “Define your button text”
  • color: “set a button text color code”
  • border: “set a border to the button”
  • background-color: “set a button background color”

last_thumb[2]

Applying a condition to the button:

Further more, you can customize the button to apply when a condition is true (e.g. – show a button only when the Flow have not started).

In this case, I’m going to tweak my approval Flow a little bit to maintain the status of the library items. The purpose here is to update the status of a item which is initiate for approval but still “Pending” as we using a custom status column here.

Tue4

By modifying the Approval Flow, I am adding a new step (SharePoint Update item action) to my existing flow. This new step has to be placed before the starting the start. At this stage, I have to set the status as “Pending” (static string).

ast

Then the same action added to both ending paths in order to update the status column up on “Rejection” or “Approval”. At this stage I can simply use the “Response” variable to pick up the current status value and update the “Status” column.

Tue3

Once added, it’s position looks like below.

Tue1

Define the Site URL, Choose the target library, pick the ID attribute and Response variable as shown below. Repeat the same for “No” path as well and that’s all we need to do here.

Tue2

That’s it from the Flow and we can head back to the Library to do the appearance tweaking. Go the column format mode and notice the changes I have done here. Apart from the color and background changes which I did to the button earlier, I have added a condition to display the button only when its true. Under this logic, the button would only appear when the status column = empty (“”), meaning the Flow have not started for a respective item in this library.

Tue5

And, as expected ! the logic is right therefore the condition perfectly applies. I have few documents in this library with mixed statuses (Rejected, Approved, Pending and of course some are not started yet). The button only showed for the items which are not gone through the Flow.

Tue6

Microsoft reference for JSON based column formatting is here. This article has covered many perspectives of column formatting.

And ! here’s the full JSON code of this customization which you can reuse if you have a similar use case.

If you want to start from the beginning, go ahead and read my previous article.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "span",
  "style": {
    "color": "#0078d7"
  },
  "children": [
    {
      "elmType": "button",
      "style": {
        "border": "light",
        "background-color": "yellow",
        "color": "#0078d7",
        "cursor": "pointer",
        "visibility": {
          "operator": "?",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Status]",
                ""
              ]
            },
            "visible",
            "hidden"
          ]
        }
      },
      "txtContent": "Send to Approval",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "{\"id\": \"e290feff-0013-41f2-97dd-91a37fb84ea0\"}"
      }
    }
  ]
}

Add a button in to a SharePoint List/Library to trigger a Flow (part 01)

Part 01 (This article)

Microsoft Flow together with PowerApps undoubtedly revolutionizing the process automation in modern work places. You may have a Flow attached to a document library or list but there is no easy access to initiate that flow from the list/library itself. People have to dig in a little bit to initiate it and that’s a little bit of time consuming for constant usage.

clip_image001

With this article, we will find out how we can overcome this struggle using a little bit of JSON stuff (Don’t worry about that word, you don’t need to be a developer here). Using the Modern SharePoint capabilities, we can embed a button right in front of every item in a list or library so that people can trigger a Flow right there. New column formatting is a cool out of the box capability to get this done.

Now let’s get this started. First and foremost, you need to have a Flow created in place and have the GUID of it.

We’ll get a Flow created really quick in case if you don’t have one. If you have a Flow already in place, you can skip these basic steps

Open up your SharePoint Library and click on the “Flow” drop down on the ribbon as below. Then go to “Create a Flow

1

You’ll see a list of available templates. You can utilize these templates if your requirement matches with them. Or simply feel free to create your own. Thankfully, there are a lot of templates published by Microsoft and the community which you can re-use on various scenarios. Unless the requirement is very specific or you are really keen on creating one your own, there is no point of designing a Flow from the scratch.

2

I am adding a simple “Request Manager Approval” flow here. Pretty straight forward.

4

Next, go ahead and check if the flow is added to “My Flows” section. If so, you are good to go.

5

Now go inside the created Flow by clicking on it and copy the highlighted GUID form the address bar of your browser. We need this for our new Button.

6

https://asia.flow.microsoft.com/manage/environments/Default-f50d518a-e13c-4359-85f6-ef76484f4c32/flows/e290feff-0013-41f2-97dd-91a37fb84ea0/details

Now to add the button but before that we need a new column for this button. From the list or library, go to the very end horizontally and add a new text column to this list/library.

10

11

It should be like below after adding. You can edit this view by dragging and dropping the desired column across the library if you wish to. I’m calling mine “Approval” so it makes scenes for a column contains buttons.

a

Now, go ahead and format this column. Click on the little arrow on the newly created column and go to format mode.

b

And paste the JSON code below. replace the GUID using the target flow which you have copied to the clip board.

c

Here’s the code (you will have it provisioned as you go to format mode itself).

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "span",
  "style": {
    "color": "#0078d7"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "Flow"
      }
    },
    {
      "elmType": "button",
      "style": {
        "border": "none",
        "background-color": "transparent",
        "color": "#0078d7",
        "cursor": "pointer"
      },
      "txtContent": "Send to Approval",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "{\"id\": \"e290feff-0013-41f2-97dd-91a37fb84ea0\"}"
      }
    }
  ]
}

That’s it and you will immediately notice the button applied to your column. This is how my library looks like after adding the button. It still doesn’t look like a button because of the border, background and colors of it.

14

Cool thing is ! you can customize the button to look like as you want it to be. Further more, you can also make it a logical button which has a condition behind it. (e.g. – show a button only when an item pending for approval).

Read the part 02 of this article series to further customize the button and apply conditions.

Detailed Microsoft article for this is here

DISCLAIMER NOTE: This is an enthusiast post and is not sponsored by Microsoft or any other vendor.

Microsoft Flow in a real world scenario: using Office Quick Parts to fill out documents (Part 01)

Part 01 (This Article)

Yes ! a simple and yet solid Microsoft Flow can be configured to fill-out a Word Document stored in your SharePoint library in conjunction with Quick Parts.

7-AutomationCrosstheNation-1600x900-1600x900

Image Courtesy: brookfieldinstitute

With this blog series, I’m going to demonstrate, how you can utilize legacy and yet famous Office Quick Parts with Microsoft Flow to optimize your content creation!. Well, Quick Parts aren’t new, they have been in Office suite since 2010 but still being famous among content creators due to its usability. 

To get started, you need the following fundamentals:

  • Office 365 subscription with SharePoint, MS Flow Capabilities
  • A document library to store documents
  • Microsoft Office Application Installed in your PC or Mac

Once you have them, simply log in to SharePoint online and open up the desired site. You need a document library to store documents and also relevant fields (metadata) to be created to match our quick parts (Date, Company Name, Project Name etc..).

In my case, I have a simple library with few metadata fields created as below.

A

Following fields in blue, are our quick parts that we will be linking with the SharePoint library fields. They can be belong to a content type (centralized) or a specific to an library, nevertheless we can use quick parts in a document so that anyone can easily fill them out as part of a process.

Today4

Once you have added columns in to the library (much more easier in Modern SharePoint experience!), create a new Word document in that library or if you already have a document, just upload it to the library (just drag and drop). my library is the default “Shared Document” and the columns are “Customer, Project name, Date, Project value”, just four, simple !

Once you have uploaded, open it from Word application as shown below.

Today1

From Word, direct to Insert –> Quick Parts –> Document Property –> Choose the desired field/s

Today2

Here I’m adding Customer field which looks like below once added.

Today3

You have to click on each spot where you want Quick part to be placed and it will insert accordingly. I have added some fields multiple times here which is perfectly fine. Normally, a single field value can be used in various location across a document.

Today4

Changes are usually saved automatically. If you notice the save icon on the top bar of Word Application. So just go ahead and close this now.

Today5

Let’s head back to our library and get started with building the Flow for this scenario. Its easier to work with any office 365 tool nowadays due to the ultimate UI enhancements Microsoft have recently done.

Click on Flow –> Create a flow, from the Library

Today6

You will now be redirected to Flow web site and you must sign in using your O365 account to be able to go ahead from here onwards.

Once you signed in, choose New –> Create from blank from the Microsoft Flow home page. Pretty simple right ?

Today7

Type in “Manual” and hit “Enter” to search. Select the “Manually triggered button” as shown below.

Today8

Next up, we have to choose our SharePoint action. Type in “Get File Content” and select the highlighted action to proceed.

Today9

On the trigger options, Choose appropriate input types to match your fields. Keep in mind that your trigger can be whatever you want it to be, in my scenario, I’m using a manual trigger which is easy for me to demonstrate the use case.

Today12

Now to format our input parameters in the trigger. In my case, I’m adding 4 input types (Date, text and number) according to the Quick Parts I have. You can have more or less, inputs based on your story.

Customer: Text Field | Amount: Number | Doc Date: Date | Project: Text

Today13

Next up, is to configure our 1st SharePoint action to act as we want. we have to bind our SharePoint library to the flow. Choose the site where you have the library from the dropdown. I am using SharePoint because, in this case that’s is where my data resides, but, you can use various other services such as Salesforce, or PowerApps to bring inputs in to the file. The idea of this post is to demonstrate that how data coming from (anywhere) can be automatically entered in to a Word document.

Today10

And select the document library from the listed ones. Leave “Infer Content Type” as Yes as well.

Today11

Now let’s add a new action here. Click on “New” and add the Create File SharePoint action as below.

Today16

This action will update the file properties when the flow is triggered. Select the Site address and folder path (Library). Define the File name by choosing the appropriate fields as you wish. File content should come from the File Content Action itself.

Today17

Once this is done, the Flow so far would look like this. make sure you map the fields properly so you wont have any errors during the first run. A positive first impression is something awesome you know that !!

Today18

Then, click on “New” and search for “Update file properties” SharePoint action from the list to add our next action.

Today19

In here too, we have to configure some parameters to reflect fields and quick parts appropriately. Choose the same site and libraries and Item ID should be “Item ID” from create file. I am using Customer Name field as the title here but its up to you to have your own choice.

Today20

Continue to read part 02

DISCLAIMER NOTE: This is an enthusiast post and is not sponsored by Microsoft or any other vendor.