saving mail attachment with PowerAutomate to sharepoint corrupts the file - sharepoint

I am trying to build a flow based on the PowerAutomate template
Create Planner task and add attachments to SharePoint on new email
arrival
This template works fine, in that it saves all the mail attachments to my sharepoint. But it only shows the link to the last attachment in the task.
I have worked around it, by adding a string variable and appending all the sharepoint paths to this variable.
With my Flow, everything runs smoothly. But the stored files are about 10%- 20% bigger in size than the original and they turn out to be corrupted.
The only difference I can spot in the saving of the file is as follows:
Template section has "get attachment" and the according "body('get attachment'):
While my in my version I can only select "get attachment (V2)" and the corresponding "body('get attachment (V2)')
There is an option with V2 that allows or disallows chunking, but there is no effect on my filesize.
The other difference is, that I have my flow create a different folder based on the task ID, since there where errors, if the same name attachment came a second time. But I have tried my flow without the added folders and there is no difference in file size.
The original files:
and the corrupted files:
It makes no difference if I use the sharepoint link provided through the flow to my new planner task, or if I open the files directly within sharepoint. The result is an error.
Can anyone guess, why my flow seems to store something more within the file and thus corrupting it? I can provide the other parts of the flow in more detail too. Here is the overview of my custom flow:

I actually found the answer after rewriting it from scratch:
Using the old template had me looking for the wrong information when adding the attachment content to sharepoint. I had always searched for "body" which was used in the template and gave me this
But searching for attachment the dynamic content actually showed me the right pieces. I am not sure, if I missed it before, or if recoding a template hid them somehow. With the rewrite from scratch I found this:
So, to make a long story short: Use "Content Bytes" of the "Get_Attachment_(V2)" Method and everything works fine.

Related

Sending recently created Sharepoint-file as attachment with Power Automate

After some months I could say I am getting the hang of Microsoft Flow, however I could use some help with the following issue:
In a flow for reporting purposes, a temporary file (.xlsx) is created in a sharepoint folder by means of a template. This temporary file is then filled with rows and info from other sources. So far so good.
I use the body of this newly created and furnished file as an attachment for an e-mail to the chief. However, the attachment came out identical to the (empty) template file, without the rows and furnishing.
Adding a delay of two minutes before attaching and sending the mail solved it for relatively small reports, but this is not ideal as I want it to work regardless of file size. Furthermore I do not understand why it would send an empty (old) version of the temp. file in the first place, as all the furnishing operations should have executed before copying and attaching (the flow is entirely in series).
Sorry for the long story. Does anyone have a more elegant solution than using a Delay-node?

Issue Getting Attachments from Email in Microsoft Flow/Power Automate

I'm currently building a new ticketing system for my workplace. When an email is received it generates a ticket number and few files in a SharePoint document library. One of those folders is "Attachments" where the flow I am building is supposed to put any attached documents. As far as I can tell I've followed other guides to the tee, however it renders the attachments un-openable. After downloading the files it did make and opening them in Notepad++, the content of the files is completely different and I can't seem to figure out why... I've been testing mostly with *.docx files, but it does the same for other file types as well. Please see attached screenshot of the attachments getter part of the flow. Any support is greatly appreciated!
Attachment Getter Screenshot
Note: This is how the guides told me to do it, however I did try changing the "File Content" box to "Attachments Content" instead of "Current Item" from the dynamic content menu to no avail.
Try use attachments content directly:
How to save Email Attachments to your SharePoint Document Library
Can you try to get the file content.
File content should help getting attachment. You will have to recreate a file though.
For this problem, please check if you have set the value of Include Attachments in the trigger to Yes.

Check share point if file exists in a shared document folder with power automate

I am trying to get the attachments of some emails and check if that attachment already exists in SharePoint. However, since the flow may have already run over some attachments that have already been received, they may or may not already be in SharePoint, so I first have to check SharePoint if the attachment exists and if they don't, create the file using the email attachment content.
So what I have so far is replicating a process that was described here
The problem that quickly arises is that under "Get file content using path" action, the File Path input box(circled below) won't let me append a file path that isn't currently already in a document folder.
Not sure if this is still a valid way to accomplish it or if there's another way. I have checked all over the place and still haven't been able to find a solution. If there's anybody that can help it would be greatly appreciated!!
To tackle this what you can do is to create a variable using Initialize variable action and compose the path e.g. '/DocumentLibrary/file.ext' that you want to check if exists. then you can refer to that variable in your folder path box for Get file content using path action. Please see the screenshot:
Next you can configure run afterfor file creation action and create file if Get file content using path action has failed, otherwise do other stuff that is required. I have tested this for sending different emails based upon file found or not found and it works well.
Hope this solves your issue.

Extract Keywords from Office Documents with Sharepoint Flow

I am trying to implement a document management system using Sharepoint. One major issue is that colleagues cannot find documents in the current setup (local fileserver). They have asked that we have a system that scans uploaded documents and automatically looks for keywords in them and then populates a "Meta" column.
I have had sort of success with OCR on image files, but getting keywords out of office documents (doc, xls etc.) I have had no success until now.
Is there a way to setup a flow to do this task for me?
any help is much aprechiated.
i tried "Get file metadata" and Azure "Text analysis", but it seems to take the raw data of the files (XML I assume) and returns that the document is to large to analyse.
There is something vague about this requirement - how is a keyword defined in a document?
Therefore, first obvious solution would be to assign keywords for each file upon uploading it. You may create a process for this with flow - have tasks, reminders and so on.
Automating this with OCR first means that you need to user OCR that works with MS flow you have only one choice - ElasticOCR. Then, in your flow
- feed the document content to the ElasticOCR action
- keep in mind that OCR is not 100% accurate
- analyze the generated text content according to your keyword definition
- finally write the meta back to the library in the corresponding columns.
Having worked on a similar requirement, we asked uploaders to publish their documents with a short abstract(column from the content type). The assumption is the abstract contains the keywords and is stored in a multi-line column - making it searchable site wide.

Append a dynamically changing watermark to a PDF in SharePoint

This is primarily a question of possibilities more than instructions. I'm a programming consultant working on a WSS project site system for my client. We have a document library in which files are uploaded to go through a complex approval process. With multiple stages in this process, we have an extra field which dictates what the current status of the document is.
Now, my client has become enamored with the idea of PDF watermarking. He wants the document (which is already a PDF) to be affixed with a watermark corresponding to the current status, such that with each stage of the approval process the watermark will change.
One method, the traditional method for PDF watermarking, of accomplishing this is to have one "clean" copy of the document somewhere hidden on the site, and create a new PDF from it that has the watermark at each stage of the approval process. Since the filename will never change, this new PDF can be uploaded continually to a public library, always overwriting the old version and simulating a "dynamically changing watermark". However, in the various stages there will also be people uploading clean copies with corrections and suggestions, nevermind the complex nature of juggling around two libraries and the fact we double the number of files stored. My client and I agree that this is not a practical path to choose.
What we would like to do is be able to "modify" the watermark in a PDF, so that we only have to keep one copy of the file. Unfortunately, from what I've seen, in most cases when you make something like a watermark, which in its nature is supposed to be "unmodifyable", you won't be able to edit it later. So, is it possible to have a part of a PDF which cannot be changed by anyone who downloads the file, but can be changed as part of a workflow or other object model process?
PDF Watermarking in SharePoint is a common request. I have written extensively on this topic. See:
Adding a dynamic watermark to a PDF file from a SharePoint Workflow
Adding a (static) watermark to a PDF file from a SharePoint Workflow
Use SharePoint Workflows to inject JavaScript into PDFs and print the ‘open date’
You could use Event Handlers such that code was run every time a document was checked in. In that code you could perform the fixup/check that made the watermark be what you wanted it to be. This assumes you can write code that manipulates a PDF's internal structure such that it has the watermark that you desire.
It sounds to me like you want to allow people to modify the PDF they download, but not modify its watermark. This is probably going to be nigh on impossible if the watermark is embedded in the PDF (afaict) but what if the watermark image is external to the PDF; is it possible to embed a watermark in a PDF that is sourced via HTTP? Then you could embed:
<watermark image="http://sharepoint/site/_vti_bin/docstatus.asmx?id=5">
Of course, I have no idea about PDFs, so this might not be possible but you get the concept.
-Oisin
It is possible to do so if you use third party tool. Then you can put dynamically binded value from your SharePoint metadata, conditions, rules etc: http://www.pdfsharepoint.com

Resources