- Hello, welcome back to another video in this video I'm going to
show you how to embed images in an email center from power automate. Now, there are a few
different ways of doing this but the most reliable way
is to encode the image as base64 into the email. This is the image that we're
going to be using for a test and it is in SharePoint. So, if we first look at
this flow, it's very simple. We do get file content using path and that is the path to our image. Notice that it's a PNG file, and I'll show you why that is relevant. We click test on there and look at the outputs of this action. We can see the content type is image JPEG and dollar content is the
base64 contents of that image. So our send an email V2 action has got that value from
above in image for slash PNG and then the base64 encoded version of it. And that is achieved via
these two expressions here. (keyboard chattering) It's here, body content type body content. So they will give you that base64 output. Now this works pretty well. Here's the message. But what you will notice is that not all email clients support
this base64 encoded image. If I go to my Gmail, (keyboard chattering) we will have the same
message that's just been sent and there is no image. Some email clients prefer the image to be linked out on a
publicly accessible website instead of embedded inside the image. Now, if you want to get this code, you can get it from the blog post, which is linked in the description, but if you want it to work for everybody you're going to need to
make that image available on the internet. So, your first option is to
use an image hosting service or put the image on your website, but if you still want to serve
the image from SharePoint you can do that. So we're going to do this, when a HTTP request is received, we look at the advanced options. We can see this get action, and in the relative
path, we've got pick ID and then in curly braces pick ID, and that pick ID represents the ID of the image in this folder. So our power automate test image is ID 24 but there are a whole bunch of
other images in here as well. So to get file content, and we'll use the identifier that comes from get file properties and then response, we
just put file content. So if I take this URL here and paste it into a new tab, here is the pick ID. So if I put 24 into that, it will bring us back our image if I change it to 23, we got the other image, it's actually an animated GIF and you can see it automatically adjusts the content type based
on the kind of image. So using this flow as a server, we have a look at this flow, I've got the image ID
hard-coded into a compose, and then I'm creating the tag the IMG, HTML IMG tag in this compose, and I'm putting the
outputs of the image ID into the pick ID. Then I'll use the Send
email action as before, so if I test that this will work in both outlook and it should work in Gmail as well. See what we got. Now, as you can see, because that image
wasn't inside the email, it just took a second to load there, and if we go back to Gmail, there we go, it loads
up no problem at all. And if we just view the source you can see that the image
source is our HTTP trigger with the pick ID of 24. So that is another way
that you can embed images without actually putting
the image inside the email, and if we have a look at size, lets put that onto there So you can see, the size of
the second email is much less, it's 48 kilobytes versus 102. This one has got them, the
image embedded in the email, and this one downloads it. Obviously, if you're sending this email to a lot of people that is going to execute
this flow every time that image is requested. So that's just something to be aware of. Everything you need to recreate
these closes on my blog. So visit there and download them, let me know how you get on and if you get stuck, I
will try to help you out. Good luck.