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 / How to build flow that...
Power Automate
Unanswered

How to build flow that sends email with attachments

(1) ShareShare
ReportReport
Posted on by 21
I am new to creating flows and have been watching videos/reading threads to help get me to the flow I currently have. That being said I am unable to figure out the next step to get my flow working correctly. I am trying to set up a flow that is triggered when an item in the list it set as "completed". I want the flow to send an email to a few users and include any attachments that were uploaded in reference to that item. Usually just 2 files, an excel and a pdf file. The set up I currently have is as follows: When an item or a file is modified>Get changes for an item or a file (properties only)>Condition. 
 
I am attaching screenshots of what my "Condition" action includes. When testing my flow, I am receiving the email with an attachment that does not have a file extension, test results are showing that the flow is successful. The attachment gives me an error when trying to open it. I do not know how to tell the flow to gather and send the attachments properly. I have tried seeing help videos but am unable to comprehend or just don't know at all how to make them work with my flow. I am attaching screenshots of the way the file attachment is coming in through email and the error I get when I try to open it. Error says: "Adobe acrobat cannot open (test 002) because it is either not a supported file type or the file has been damaged (for example, it was sent as an email attachment, and wasn't correctly decoded).
 
I need the email attachment name to appear just the same as what was uploaded to the list. Any help is appreciated. Please let me know if screenshots are not helpful or blurry. I want to mention that this is not the entirety of what I need my flow to do. I am also wanting the flow to save the attachments that are being emailed into a specific drop box folder. Don't know if this extra action will make a difference in the way my flow needs to be set up. I have tried to take it one step at a time and figured it would be best to get the email attachment part working first before moving on to this next action. 
Categories:
I have the same question (0)
  • MiDer Profile Picture
    139 on at
    Currently you provide in your e-mail the value of the property 'has attachment'.
    This is either true or false and does not represent the attachments content.

    Out of all the below shown actions, only the last one gives you the list item attachments in return:
  • MuchTooMany Profile Picture
    26 on at
    You're nearly there
     
    You need to initialize an array variable for use later. Then you need to use the "Get attachment content" action.
     
    Append the following to the array variable:
     
    {
    "Name": [desired filename],
    "ContentBytes": body('Get_attachment_content')
    }
     
    You'll get a for each loop around get attchment content, so the desired filename should be dynamically set from your existing get attachments
     
    Then add the variable in the attachments portion of the send mail action. You'll need to click the switch to input array option
     
  • yellowsquirrel Profile Picture
    21 on at
    I have added the "Get attachments" action you have guided me to, in the fashion shown below, not sure if this is correct placement for that action. However, the email is still not properly fetching the attachment. I am not sure what the "apply to each is referring to" it populated on its own with the "Body" dynamic content. Can you please review the screenshots attached. The email is attaching the item name "2204-01" rather than the actual attachments (not visible in the screenshot I sent, but there is a column in my list that contain attachments which have been user uploaded to the form, I assure you). I apologize in advance as I have very little knowledge how to work these functions, but glad to slowly be making progress. See screenshot showing how attachment in coming in through email.
     

     
     
     
     

     
     â€‹â€‹â€‹â€‹â€‹â€‹â€‹
     
     

     
     
     
     

  • MuchTooMany Profile Picture
    26 on at
    No problem, but I can't see the array variable or Get attachment content action?
     
    • Add the initialize variable action before your Condition. Give it the name 'Attachments', set the type to array, and leave the value blank. 
    • Add the 'Get attachment content' action after Get attachments in your switch case - set the Id to 'ID' from When an item or file is modified, and the file identifier to 'id' from Get attachments. This will put it into an apply to each container.
    • Add the 'Append to array variable' action after Get attachment content in the apply to each. Set the value as the code below, where the name  is 'DisplayName' from the dynamic content of Get attachments, and ContentBytes is the dynamic data 'Attachment content' from Get attachment content. No spaces after the colon/before the comma.
    {
    "Name": ,
    "ContentBytes": 
    }
    • Delete your apply to each container and recreate your email action. On your email action, click the 'Switch to input entire array' option and add the dynamic content from your variable.
    • Save and test.
  • yellowsquirrel Profile Picture
    21 on at
    Thank you @MuchTooMany! It is working and I'm able to send multiple attachments in a single email! Would you be able to guide me in how to get the attachments that have been emailed to save to Dropbox. I'm afraid the flow is now beyond my comprehension and have no clue how to approach this part. 
     
     
  • MuchTooMany Profile Picture
    26 on at
    I'm glad I could help. Please mark my reply as the answer to help others in future.
     
    I don't use Dropbox so I am unfamiliar with it in practice. However, looking at the dropbox 'create file' action you need to define the folder, filename and file content.
     
    You could try adding the dropbox create file action after the email action, defining the folder you want the attachments to go into, and then use the dynamic content you used in append to array variable (DisplayName & Attachment content) for the filename and content.
     
    As I say, I don't have dropbox so I am only surmising, but it's worth a try.
  • yellowsquirrel Profile Picture
    21 on at
    Thank you for trying to help out. It was definitely worth a try, however when using the "create file" option, "attachment content" is not an option from the dynamic content list. I will create new question for this part of my flow to try to get some more feedback. Also, for some reason I am not able to set your answer as the solution. I have been trying endlessly since yesterday. When I click on "Does this answer your question", all it does is show the little circle loading and never performs the action no matter how long I let it load and does the same on both Microsoft edge and Chrome browser :[ .. If you want I can repost same question and try again to set your reply as answer..? Don't know if you would be able to find my question again though..?
     
  • MuchTooMany Profile Picture
    26 on at
    Ah, yes, because the DisplayName is an array so it puts it into an apply to each. My bad.
     
    As we're happy the attachments are being emailed correctly, we can create the file in dropbox first before it sends.
     
    Move the dropbox create file action to 'Apply to each' under your append to array action. That should give you access to all the dynamic data and you can test whether it works writing the files to the folder in dropbox.
  • yellowsquirrel Profile Picture
    21 on at
    Thank you, the flow runs as successful, but no email attachments are to be found in the folder. The Dropbox is a company shared Dropbox. I hardly ever access the Dropbox through my browser, rather I have it set up to where the folders I need are synced to my desktop. When I click on the little folder icon in the "Folder Path" blank, there are two options that are given as paths. One option shows my name as the first folder, the other options does not show my name as a folder to the path.  The folder with my name is not a folder I manually created, I guess it's just like my user folder..? I've tried it with and without my name in the first part of the Folder Path, both tries give me green test results but still no file to be found in folder. Do you have any advice??
     
  • MuchTooMany Profile Picture
    26 on at
    I have tested the dropbox create file on my personal computer and it works. 
     
    However, there are 2 things with this: 1) I don't have sharepoint on that so I used OneDrive instead, and 2) my personal dropbox is just mine, so not a shared business one.
     
    I was able to get the filename and content from OneDrive 'When a file is created' and then use those in the dropbox 'Create file' action. Do note that this is not the OneDrive for Business connector - if you use that you don't get the file content from create file and would need to use the 'Get file content' action afterward.
     
    Reading the dropbox documentation, this seems pertinent:
     
     
    The folder with your name is clearly personal. Are the others shared or team?
     
    Could you share a screenshot of the dropbox action output from the successful ("green") run?

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard