cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MelG
Level: Powered On

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
ck25415
Level 8

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

@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.

 

MelG
Level: Powered On

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

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. 

ck25415
Level 8

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

@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

MelG
Level: Powered On

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

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. 

ck25415
Level 8

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

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.

MelG
Level: Powered On

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

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???

ck25415
Level 8

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

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.

MelG
Level: Powered On

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

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 195 members 5,673 guests
Please welcome our newest community members: