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

Apply to Each is triggering twice for some reason?

Hi there!

 

Trying to make a flow to take an incoming email, grab the attachment, and send out the attachment in a different format.

 

The incoming email always has only one attachment, but Flow seems to believe it has two? And so whenever I add the attachment to my Send an Email card it puts it in an Apply To Each loop, and send out the email twice?

 

Here's what it looks like:

 

 

How can I:

 

a) Limit the Apply To Each loop to only occur once?

 

or

 

b) Make Flow realise there is only one attachment and take it out of the Apply To Each loop?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @ryans32229,

 

Please take a try to add a Condition under the Apply to each to check the Content type.

 

Capture.PNG

 

Or you add a expression in the Condition as below to check if the content type contain value "image":

@contains(items('Apply_to_each')?['ContentType'], 'image')

 

Please let me know if your problem could be solved.

 

 

Best regards,

Alice

 

View solution in original post

7 REPLIES 7
Community Support
Community Support

Hi @ ryans32229,

 

Could you please share a screenshot of the run details of your flow?

 

If the incoming email always has only one attachment, the apply to each in the flow would only run one time and will not have a loop.

 

I afraid that you have two incoming emails arrive so the flow would run two times, so the email would be sent twice.

 

Please make sure the incoming email has only one attachment and see the run details of the flow.

 

Please let me know if your problem could be solved or show more details so we could provide a proper workaround for you.

 

Regards,
Alice Zhang

@v-yuazh-msft

 

Thanks for the response

 

Here is the run details:

 

 

As you can see the Apply To Each card is running twice.

 

The incoming email is a Power BI subscription, so it will definitely only have 1 attachment (a .png of the dashboard).

 

What more details would you like to see Alice?

 

Thanks

Hi @ryans32229,

 

The applay to each have run twice in one flow run as you said.

 

Please check the run detail of the trigger in your flow, and copy the details in the Body of the output of the trigger, you could paste the body in a notepad, see the two attachment of the email.and check the name of the extra attamment,idendify what file it is and why it is sent as the attachment.

Capture.PNG

 

 

Best regards,

Alice

 

 

Hi @ryans32229,

 

The applay to each have run twice in one flow run as you said.

 

Please check the run detail of the trigger in your flow, and copy the details in the Body of the output of the trigger, you could paste the body in a notepad, see the two attachment of the email.and check the name of the extra attamment,idendify what file it is and why it is sent as the attachment.

Capture.PNG

 

 

Best regards,

Alice

 

 

Hi @ryans32229,

 

The applay to each have run twice in one flow run as you said.

 

Please check the run detail of the trigger in your flow, and copy the details in the Body of the output of the trigger, you could paste the body in a notepad, see the two attachment of the email.and check the name of the extra attamment,idendify what file it is and why it is sent as the attachment.

Capture.PNG

 

 

Best regards,

Alice

 

 

Hi @v-yuazh-msft

 

Here is the attachment section of the body details:

 

 

  "Attachments": [
    {
      "@odata.type": "#Microsoft.OutlookServices.FileAttachment",
      "Id": "AAMkADM3NDJjZTAzLWIzYjktNGQwMi05N2M3LTdhNmVjYWQ4MjczOQBGAAAAAACSAIlHLdzxRLYalGwoVqlGBwBne0HwvqbaSq7XSbrN58bxAAAAAAEMAABne0HwvqbaSq7XSbrN58bxAABMC24xAAABEgAQAEowcGbLe9VOrCK8t7Jnjbo=",
      "Name": ",********,ryan.s*****@*******.co.uk.png",
      "ContentType": "application/octet-stream",
      "Size": 25957,
      "ContentBytes": "iV..."
    },
    {
      "@odata.type": "#Microsoft.OutlookServices.FileAttachment",
      "Id": "AAMkADM3NDJjZTAzLWIzYjktNGQwMi05N2M3LTdhNmVjYWQ4MjczOQBGAAAAAACSAIlHLdzxRLYalGwoVqlGBwBne0HwvqbaSq7XSbrN58bxAAAAAAEMAABne0HwvqbaSq7XSbrN58bxAABMC24xAAABEgAQAAafp6PtI-pKmlDhlnSimhY=",
      "Name": "959d496b7c39497c8375e9d71b60e91c",
      "ContentType": "image/jpeg",
      "Size": 25833,
      "ContentBytes": "iV..."
    }
  ]

As you can see it is indeed finding 2 attachments, however in the incoming email in my Outlook it only shows 1. Is it possible one of these is an 'invisible' attachment?

 

 

Either way, how can I get Flow to only pick up the image/jpeg attachment, and ignore the application/octet-stream one?

 

Thanks

Hi @ryans32229,

 

Please take a try to add a Condition under the Apply to each to check the Content type.

 

Capture.PNG

 

Or you add a expression in the Condition as below to check if the content type contain value "image":

@contains(items('Apply_to_each')?['ContentType'], 'image')

 

Please let me know if your problem could be solved.

 

 

Best regards,

Alice

 

View solution in original post

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 (21,543)