My proposal with one Apply to each that loops over the Attachment types (just to have less actions in the flow):
Apply to each (Attachment type) is an array of arrays of the types you are looking for (you probably want to add some more types)
[
[
"image/png"
],
[
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/pdf"
]
]
FilteredAttachments checks if there are Atachments with these types
From
@triggerOutputs()?['body/attachments']
Filter
@items('Apply_to_each')
contains
FilteredAttachmentNames gets the names of these attachments
From
@body('FilteredAttachments')
Map
@item()['name']
Compose the resulting object that you might add as a row to your Excel file
{
"Subject": @{triggerOutputs()?['body/subject']},
"Sender": @{triggerOutputs()?['body/from']},
"Image Files": @{join(body('FilteredAttachmentNames')[0], ', ')},
"Document Files": @{join(body('FilteredAttachmentNames')[1], ', ')}
}
The Compose's output looks like this:
{
"Subject": "Just a test",
"Sender": "Chriddle@example.com",
"Image Files": "io.png",
"Document Files": "Manifesto of the Communist Party.pdf, A Contribution to the Critique of Political Economy.pdf, test.docx"
}