web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Suggested Answer

Send email v2

(2) ShareShare
ReportReport
Posted on by 54
Hi, can you please help me. Got an error attaching multiple files.
 
 
 
 
  • Suggested answer
    CU16071609-1 Profile Picture
    6,255 Moderator on at
    Hi  ,
     
    The error is occurring because you are sending a list of text values instead of a list of custom objects in your email. Please correct this to resolve the issue.
     
    Regards,
    Deenu
  • Suggested answer
    eetuRobo Profile Picture
    4,607 Super User 2026 Season 2 on at
    As @Deenuji Loganathan pointed out you need to have List of custom objects for the attachments. 

    I would not use list but just set variable.

    Here is how you can make it work:



    Send an email (V2) Attachemnts field put the %Attachments% variable


    Here is code for the actions (other than the Send an email V2 since it has connection reference that would not work on your flow).
    Folder.GetFiles Folder: $'''C:\\Users\\YourUserName\\Documents\\Test''' FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
    SET FirstFile TO True
    LOOP FOREACH CurrentItem2 IN Files
        File.ConvertToBinary File: CurrentItem2 BinaryData=> BinaryData
        IF BinaryData = $'''Byte [0]''' THEN
            # No file. Might be folder so go to next loop.
            NEXT LOOP
        END
        File.GetPathPart File: CurrentItem2.FullName RootPath=> RootPath Directory=> Directory FileName=> FileName FileNameWithoutExtension=> FileNameNoExtension Extension=> FileExtension
        IF FirstFile = True THEN
            SET FirstFile TO False
            SET Attachments TO [{ 'Name': CurrentItem2.Name, 'ContentBytes': BinaryData }]
        ELSE
            SET Attachments TO Attachments + { 'Name': CurrentItem2.Name, 'ContentBytes': BinaryData }
        END
    END
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 331 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard