cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
G99
Post Prodigy
Post Prodigy

Adding attachment(s) or link to attachment(s)

Hi all,

 

I wonder if there is a way of adding attachments to an email flow sends on a daily basis, and displays the previous days entries in to a SharePoint list.

 

I have attempted the following but got an error, which I believe is related to the get attachment and get attachment content not being the parent.

My issue is, my Send Email action, contains some actions from the previous loop, so only 1 will work, either the convert time loop or get attachment loop:

G99_0-1617813269432.png

If i try it this way, I cannot add the output from the HTML table:

G99_0-1617886844570.png

 

 

any suggestions please, worst case scenario would be to add a link to the item, but unsure how to do that?

2 ACCEPTED SOLUTIONS

Accepted Solutions
tom_riha
Super User II
Super User II

Hello @G99 ,

you'll need 'Apply to each' separate from all the 'Select' action, only the attachments actions should be in the 'Apply to each'. You'll need also an array variable.

  • 'Initialize variable' of type: Array
  • 'Apply to each' item from 'Get items'
    • 'Get attachments'
    • 'Apply to each' attachment
      • 'Get attachment content'
      • 'Append to array variable' the attachment

The value you'll append into the array variable should look as below:

{
  "Name": <DisplayName>,
  "ContentBytes": <AttachmentContent>
}

After all the loops you can continue with the 'Select 2' and use the array variable in the send an email action.

I wrote an article on this topic on my blog, in your situation you'll just need one more 'Apply to each' at the beginning to get attachments from all the items.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

Yes @G99 , you can use any value for the file name as long as it has the correct extension. You can for example add a 'Compose' action before the 'Append to array variable', in that 'Compose' action enter the dynamic content representing item ID, some separator character, and then the file name.

You can then use in the 'Append to array variable' the output from 'Compose' as the file name.

image.png



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

18 REPLIES 18
ScottShearer
Super User III
Super User III

@G99 

I am not clear on your requirement.  Do you want to actually email the attachments?  Do you want to send an email listing new items from the previous day that had attachments?  Something else?

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
G99
Post Prodigy
Post Prodigy

HI @ScottShearer 

 

Currently what I am doing is emailing the previous days logged items, and in my table, I am using the has attachments properties, which only displays true or false.

 

Rather than/in addition the users have asked if it is possible to include the attachments with the name being the RefNo. for those items.
If that is not possible, then a link to each attachment to be provided along with the other data the flow is providing. 
Thanks

G99
Post Prodigy
Post Prodigy

HI @ScottShearer 

Any help on this would be appreciated 

tom_riha
Super User II
Super User II

Hello @G99 ,

you'll need 'Apply to each' separate from all the 'Select' action, only the attachments actions should be in the 'Apply to each'. You'll need also an array variable.

  • 'Initialize variable' of type: Array
  • 'Apply to each' item from 'Get items'
    • 'Get attachments'
    • 'Apply to each' attachment
      • 'Get attachment content'
      • 'Append to array variable' the attachment

The value you'll append into the array variable should look as below:

{
  "Name": <DisplayName>,
  "ContentBytes": <AttachmentContent>
}

After all the loops you can continue with the 'Select 2' and use the array variable in the send an email action.

I wrote an article on this topic on my blog, in your situation you'll just need one more 'Apply to each' at the beginning to get attachments from all the items.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

HI @tom_riha 

Thanks for that
I thought I have tried what you have suggested but clearly im missing something as when I go to select AttachmentContent in Append to array variable, i cannot select it from dynamic content please see snippet:

 

G99_0-1618480641586.png

 

 

You're missing the 'Get attachment content' action right before the 'Append to array variable'.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

@tom_riha 
Aha, so I was, Thanks for spotting that.

I've been down this route (or similar) now I cannot set the Name: <DisplayName>  this does not appear
but also when I go to the send email action, I cannot select in Attachment content - the Attachment Array, it's not visible for me in the list
This was another of my errors, I had to 'switch to input entire array'

Just need to figure out why I cannot now see the display name

G99
Post Prodigy
Post Prodigy

@tom_riha 

 

Sorry I have been trying different things but cannot get the display name to appear, when you get a chance please help further:

 

G99_0-1618487928892.png

 

The 'DisplayName' should be the output from 'Get attachments' (and the reason why the 'Apply to each' was originally added), it must be somewhere among the dynamic content.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

The whole attachment processing part must be inside the first 'Apply to each'.

image.png

 

In the same way you had it before:

image.png



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]
G99
Post Prodigy
Post Prodigy

@tom_riha 

Thanks so much for your help

re-did that apply to each bit again and the flow ran successfully but the image (attachment) cannot be opened - I'll google why that wont work - this is a steep learning curve!

 

 

Remove the < and > from the value, I used them to mark the placeholder, I guess I should've mentioned that earlier 🤔. It should be only the dynamic content behind the colon (and comma after the DisplayName to mark end of line).

"Name": DisplayName,
"ContentBytes": AttachmentContent

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]
G99
Post Prodigy
Post Prodigy

@tom_riha 

Not sure I follow as I do not have <and> in there anywhere...
I found some stuff on line I tried it but to no avail:

 

G99_1-1618496832493.png

 

Now you have quotes " on the place of the < >, remove them.

image.png



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]
G99
Post Prodigy
Post Prodigy

@tom_riha 

Top man

that worked and the image is also working

 

Thanks a million for your help

G99
Post Prodigy
Post Prodigy

@tom_riha 

Sorry 1 more question comes to mind, hope you dont mind?
Is there a way of adding the RefNo value to each attachment name when its emailed?

Yes @G99 , you can use any value for the file name as long as it has the correct extension. You can for example add a 'Compose' action before the 'Append to array variable', in that 'Compose' action enter the dynamic content representing item ID, some separator character, and then the file name.

You can then use in the 'Append to array variable' the output from 'Compose' as the file name.

image.png



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

G99
Post Prodigy
Post Prodigy

@tom_riha 

 

Top man, thanks for all your help that works

 

Oddly when ever i make a change to the append to array variable, i have to re-type that entire bit in, never works when I edit, not biggy though, main thing is a very minor work around - but hopefully no further changes to it

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (46,251)