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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Send email with attach...
Power Apps
Answered

Send email with attachment

(0) ShareShare
ReportReport
Posted on by 181
Good morning, everyone!
 
I am beginner and i am making a power app to send email with multi attachment.
 
I have 5 attachment controls.
 
It is work for send email with 1 attachment control, below is my code
Office365Outlook.SendEmailV2(
    "alan@c.com.hk",
    "Subject",
    "Body",
    {
        Attachments: ForAll(
            Attachment_Inspection_Record.Attachments,
            {
                ContentBytes: Value,
                Name: Name
            }
        )
    }
)
 
But it is causing error if send email with 5 attachment control that
Unexpected characters. Characters are used in the formula in an unexpected way.
Invalid number of arguments. Name isn't valid. 'Value' isn't recognized. 
 
, below is my code:
Office365Outlook.SendEmailV2(
    "alan@c.com.hk",
    "Subject",
    "Body",
    {
        Attachments: ForAll(
            Attachment_Inspection_Record.Attachments,
            {
                ContentBytes: Value,
                Name: Name
            },
            Attachment_CCM.Attachments,
            {
                ContentBytes: Value,
                Name: Name
            },
             Attachment_Sitephoto_1.Attachments,
            {
                ContentBytes: Value,
                Name: Name
            }
            Attachment_Sitephoto_2.Attachments,
            {
                ContentBytes: Value,
                Name: Name
            }
            Attachment_Sitephoto_3.Attachments,
            {
                ContentBytes: Value,
                Name: Name
            }
        )
   
        
    }
);
 
I do not know how to revise.
Would anyone can help?
Thank you very much.
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at
    Try this format
    Office365Outlook.SendEmailV2(
       "alan@c.com.hk",
       "Subject",
       "Body",
       {
          Attachments: 
          Table(
             RenameColumns(
                Attachment_Inspection_Record.Attachments,
                Value,
                ContentBytes
             ),
             RenameColumns(
                Attachment_CCM.Attachments,
                Value,
                ContentBytes
             ),
             RenameColumns(
                Attachment_Sitephoto_1.Attachments,
                Value,
                ContentBytes
             ),         
             RenameColumns(
                Attachment_Sitephoto_2.Attachments,
                Value,
                ContentBytes
             ),
             RenameColumns(
                Attachment_Sitephoto_3.Attachments,
                Value,
                ContentBytes
             )
          )
       }
    );
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee
  • AndrianaO Profile Picture
    213 Moderator on at
    Hi! Try using this:
     
    ClearCollect(
        colAttachments,
        Attachment_Inspection_Record.Attachments
        Attachment_CCM.Attachments,
        Attachment_Sitephoto_1.Attachments,
        Attachment_Sitephoto_2.Attachments,
        Attachment_Sitephoto_3.Attachments
    ); 
    Office365Outlook.SendEmailV2(
        "alan@c.com.hk",
        "Subject", 
        "Body",
        {
            Attachments: ForAll(
                colAttachments,
                {
                    ContentBytes: Value,
                    Name: Name
                }
            )
        }
    )
     
    Let me know if this work! 
  • AT_AlanTse123 Profile Picture
    181 on at
    Thank you AndrianaO and WarrenBelz reply.
    Both of your code are work perfectly!
    Thank you very much for your help.
     
    May I ask more one question?
    How can I make these 5 attachments with specific name?
     
    Thank you.
     
  • Verified answer
    AndrianaO Profile Picture
    213 Moderator on at
    No problem! If you want to rename your files you can do the following:
     
    Office365Outlook.SendEmailV2(
        "alan@c.com.hk",
        "Subject",
        "Body",
        {
            Attachments: Table(
                ForAll(
                    Attachment_Inspection_Record.Attachments,
                    {
                        ContentBytes: Value,
                        Name: "Specific_Name_1" & "." & Last(Split( Name, "." )).Value
                    }
                ),
                ForAll(
                    Attachment_CCM.Attachments,
                    {
                        ContentBytes: Value,
                        Name: "Specific_Name_2" & "." & Last(Split( Name, "." )).Value
                    }
                ),            
                ForAll(
                    Attachment_Sitephoto_1.Attachments,
                    {
                        ContentBytes: Value,
                        Name: "Specific_Name_3" & "." & Last(Split( Name, "." )).Value
                    }
                ),
                ForAll(
                    Attachment_Sitephoto_2.Attachments,
                    {
                        ContentBytes: Value,
                        Name: "Specific_Name_4" & "." & Last(Split( Name, "." )).Value
                    }
                ),
                ForAll(
                    Attachment_Sitephoto_3.Attachments,
                    {
                        ContentBytes: Value,
                        Name: "Specific_Name_5" & "." & Last(Split( Name, "." )).Value
                    }
                )
     
            )
        }
    )
     
    You can write your new files names in place of "Specific_Name_1" etc. Also, the  & "." & Last(Split( Name, "." )).Value part makes sure your renamed files have correct extensions.
     
    Please note, that this code will work correctly if there is only one attachment per your attachment control, so make sure you set "Max attachments" property to 1 for each attachment control. 
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard