How to reconize Outlook hidden attachments with Power Automate | .eml | itemAttachment | Graph API

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello there it's gracella here in a previous video we talked about using power automate and the graph API to get the content of an attachment in an nessed email by nessed email we mean an email that we receive that the attachment is another email and the actual file we're interested in is inside that second email that is attached to the first email we got however this previous approach that we presented relies on power automate being able to recognize the EML file an actual attachment however there are some instances depending on how the email is attached it may be that par automate will not be able to recognize anything and the attachments will be empty even if the file is present there because what's really going on is that for some reason some attachments will be recognized as item attachments and not file attachments so this issue when par automate is not able to recognize the attachments this will be a totally empty array will happen when the email the attached email is recognized as an item attachment and not as a file attachment so today we're going to be working with that and showing you how to use the graph API to get the file of that attachment so in this case we're going to be working with this example because this one is recognized by power automate and the graph API as an item attachment so this is the perfect example for this scenario in which the previous approach would not work okay so let's start by going to power automate and creating an automated get Cloud flow here we're going to select the regular trigger which is when an email arrives and then assign a name then let's hit on Create and I will switch to the classic designer and once this is ready we are just going to set up the trigger to recognize the emails that start with this text so I'm just going to copy and paste it on the subject filter so so then let's just hit on new step and here we are going to be searching for HTTP what we need to select is this send an HTTP request action from The Office 365 Outlook connector what this action does is just connecting to the graph API with custom requests that we usually don't find in the regular Outlook connector so this is really useful if something doesn't work out of the box in Power automate so here what we need to do is leave the method at as get content type will stay as application Json and then we are going to write this text and after messages we are going to be selecting the message ID let's just search for ID and grab the message ID from the trigger and after the message ID we are going to extract the attachments because that's what that's what we're interested in and finally we are going to be adding some strings at the end to get the item attachment details so what we are what we are doing here is using the graph API first to extract the full list of attachments regardless if they are an item attachment or a file attachment and then we are adding these parameters at the end to indicate that we want to extract all the details of the item attachments what this will do is give us the name and the content and then we can use that in power automate to just create a file in SharePoint so for now let's hit on Save and see how this result will look Let's uh go ahead and test and send an email to ourselves to see this working okay so now it has run so let's go ahead and see what the HTTP request from the graph API looks like just going to click here on show row outputs and the first thing we're going to notice is that here the attachment we have this do EML file is an item attachment and not a file attachment like the other type we were working with in the previous video so right after we know this we know that the actual item all the details are here we can see what's the subject of that second email which is the same one that we have here as you can see and then we have some other details about the attachment and then the final thing that we have is the actual attachment data because you we have this file with we have the attachment here and inside that we have a PDF so that PDF information is what we see in the attachments section of the item details so here we have for example what's the content type what's the name and we also have the actual content of the file so what we need to do is just extract the value of the result and then go to the item and then after the item grab the first item of the attachment and then just grab the content bite and we and after that we will be able to create the file in SharePoint and extract the content of this attachment so let's just go back to edit and what we are going to be doing is adding a new step and let's select the control and here we are going to be using the appli to each what we need to do is just extract the value attribute of the body so I'm just going to select body here and I am going to copy this text and in a notepad or any text editor I am going to paste this and then grite the question Mark and then square brackets and then in single quotes we are going to write the word value which is the same word that we have here so we can extract the contents of this so I will copy this and then paste it here right after that I am going to just add a create file action from SharePoint and I'm going to select the SharePoint site that I want to set save my file into and then the path and for the file name and file content we know that that is present here in the attachment section we know that that's the first item that we have in the attachments here's the name and here's the actual content of the file and we know that this attachment attribute is under the item attribute so after extracting the value and then we know we know we are looping through it then we need we need to get to the item and inside item we need to get to attachments and inside attachments we need to get to the first element so to do that I am just going to select here on the file name then go to the very end and select current item so I'm just going to copy this and paste it in my notepad and as we have seen to go through each of the attributes or to access to each of them what we need to do is to just write a question mark and then in between square brackets we write the name of the attribute we want to access so in this case we just accessed item and inside item we want to go to attachments so I'm just going to copy this and paste it here now that we have accessed or reached attachments what we want to do is to extract the first one because we know that this file only will have a single attachment in this case that's my PDF file that I have here so after that after we have reached the first element we are going to just extract the attribute name that we are interested in so in that case let's just copy this and paste it right after the first function and then here we are going to access the name we are going to be doing a similar thing for the content bytes so I'm just going to WR this and to copy this and paste it here now we are ready to just grab the name of the attachment and paste it in the file name but for the file content we cannot do exactly that because SharePoint expects binary format to be able to create a file into this platform and the content bite that we are reading here is in base 64 so we need to convert this base 64 into binary and there's a a formula in power automate that we can use for that so I'm just going to copy my code without including the curly bracket and the ad and then I will go to the file content field and then in expression I will write base 6 for to Binary then open and close parentheses and in the middle of that just paste my code after that I will just hit okay and then hit onve once our workflow is saved I can just go back and then resubmit and it seems like it worked properly so let's go to our SharePoint folder and we can see that our file is here and it was successfully created it and we were able to successfully recognize this attachment even though the part atate Trigger or the get attachments out of the box action doesn't work we can use the cph API and this sent an HTTP request from the Outlook connector is pretty useful because we can work around many of the things we cannot do with the regular actions that's it for now we hope that this was useful for you see you next time
Info
Channel: Power GI
Views: 73
Rating: undefined out of 5
Keywords:
Id: fnyUaN6COic
Channel Id: undefined
Length: 9min 27sec (567 seconds)
Published: Mon Jun 24 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.