web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Corrupt PNG Files on E...
Power Automate
Unanswered

Corrupt PNG Files on Email

(0) ShareShare
ReportReport
Posted on by 9

Hello

 

I have some pictures that are received throughout the day into a sub folder (using an Outlook rule). I have a flow that saves them into a SharePoint folder when they arrive. At the end of the day, I want a flow to take all of the pictures out of folder, attach them individually to a single email and send the email (then remove all of the documents from the SharePoint folder). 

 

The first flow works fine. I can view the PNG files in the SharePoint folder, no problem. The second flow works in that it attaches each PNG file individually into a single email, but the attachments just say 'It looks like we don't support the file type' as though it has been corrupted somehow. 

 

I've attached pictures of my flow (I'm not going to take any credit for it, I stole it from the internet 😀). I'll look at clearing the documents once I can get the flow working as expected. 

I don't necessarily need them in a SharePoint folder. I'll happily consider other options. I just need it to work! If anyone can point me in the right direction, it'd be greatly appreciated.

 

Thanks

 

Categories:
I have the same question (0)
  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    It looks like the issue is caused by the way you're constructing your attachment objects. Below is how I would likely build the entire flow, including deleting the images after the email has been sent.

     

    For this example, I'm using the following folder to hold my images.

    grantjenkins_1-1674654052607.png

     

    Below is the full flow. I'll go into each of the actions.

    grantjenkins_0-1674654025076.png

     

    Recurrence is set to run daily at 11PM.

    grantjenkins_2-1674654117285.png

     

    Get items (properties only) retrieves the images from the folder. Note that I've also added the following filter so it only returns files (NOT folders). This means we don't have to add a Condition to check if it's a folder or file as only files will be returned.

    FSObjType eq 0

    grantjenkins_3-1674654228005.png

     

    Initialize variable creates an array variable called attachments which will eventually contain all our images.

    grantjenkins_4-1674654302645.png

     

    Next, I have a Condition to check that at least one image was returned. If no images returned (no images in the folder) then we don't progress any further (No branch). If at least one image returned, then we go into the Yes branch. The expression in the condition is:

    length(outputs('Get_files_(properties_only)')?['body/value'])

    grantjenkins_5-1674654415938.png

     

    Apply to each Attachment will iterate over each of the images returned.

    grantjenkins_12-1674654951992.png

     

    Get file content retrieves the content of the image.

    grantjenkins_7-1674654520975.png

     

    Append to array variable builds up our attachment object, including the Name and ContentBytes. Name uses File name with extension from Get files, and ContentBytes uses Body from Get file content. It then appends the object to our attachments array.

    {
     "Name": @{items('Apply_to_each_Attachment')?['{FilenameWithExtension}']},
     "ContentBytes": @{body('Get_file_content')}
    }

    grantjenkins_8-1674654649538.png

     

    After the Apply to each Attachment, we use Send an email adding the attachments array.

    grantjenkins_9-1674654697235.png

     

    We then have Apply to each Image to Delete that will iterate over each of the images returned and delete each one, so our folder is ready for the next lot of images.

    grantjenkins_10-1674654755294.png

     

    In this example, the email received would look like the following:

    grantjenkins_11-1674654842581.png


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • Yoop_eyes Profile Picture
    9 on at

    Thank you so much for taking the time to do this! Only slight modification I had to do was change the 'Apply to Each Attachment' part to 'Apply to Each'. I couldn't find a control called Apply To Each Attachment anywhere. But it works perfectly with Apply to Each.

    Thanks again. 

  • Yoop_eyes Profile Picture
    9 on at

    I now realise that you can rename the controls and feel rather foolish 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard