cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Trigger email to send when list item is modified with or without an attachment

I am pretty new to SharePoint and I have created a ticketing system that will generate out an email when a list item has been modified. I am running into a problem regarding attachments in the email.

 

Originally I created a flow that worked however it did not include any attachments listed on the list item. I created a replacement flow that would pull in the attachments but would only trigger the email if an attachment was included. I made some adjustments to it and now it sends two emails for each list item - one with an attachment and one without it. If there is no attachment then it sends the same email with no attachment listed twice.

 

What I am wanting is one flow that will send only one email. If there is an attachment to include it, if no attachment is listed, send an email with no attachment. Can someone let me know what I need to correct? Or how to create a new flow if that is what is needed. 

 

1st steps.PNG2nd steps.PNG

8 REPLIES 8
Post Patron
Post Patron

@MelG

 

Hello,

 

I have created a flow that sends an email based on the item attachment condition, the flow sends multiple attachments together in one email.

 

emailattchmentflow.JPG

 

json to append in the array avriable is 

 

{
"Name": @{items('Apply_to_each_2')['DisplayName']},           
"ContentBytes": @{body('Get_attachment_content_for_item')['$content']}
}

 

display name is selected from get attachments 2 action and for contentbytes property @{body('Get_attachment_content_for_item')['$content']} should be written in the expression window. The expression may change based on your action names.

 

Thanks,

CK

 

 

 

Accept my post as answer if it resolved your question.

 

Frequent Visitor

Could I see the drop down you have in the "Initialized Variable Attachment Array? I was originally getting an error there. I corrected it and the flow will run but I am still getting two emails. 

@MelG

 

Its just an array variable, if you are still getting two emails you might want to check if the email action is under a loop.

 

1.JPG

Frequent Visitor

Yes it appears to have the loop.

The only difference I see between your flow and mine is I have a Switch in place for the status value inbetween the Variable Array and Condition for the attachment = true.  The status is the factor that determines if an email needs to be generated. 

If you can start the reply case with if condition and move the get attachments action to under the yes branch and above the apply to each loop action and delete the apply to each loop 2 action which is causing multiple emails will resolve the issue. I am not sure if there is reason for you to have get attachments above apply to each 2 loop.

Frequent Visitor

Would you be able to show me an example of the IF condition? I believe I tried a condition and it did not work which is why I changed to a Switch condition. Maybe I have had the formula incorrect???

Hi,

 

Its a simple condition which checks the has attachments column from item created or modified action

 

emailattchmentflow1.JPG

 

Let me know if you have any questions.

Frequent Visitor

Oh yes, I originally did that and it did not work. That's when I found the switch case and that seemed to fix one issue. 

I started working on another test flow today and I have it so that it only sends one email however it does not pull the attachment in. It looks like it is set up the same as yours above just with the switch case in place. 

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (51,471)