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 Platform Community / Forums / Power Automate / Flow to send mail with...
Power Automate
Suggested Answer

Flow to send mail with attachments

(0) ShareShare
ReportReport
Posted on by 4
Hello,
 
I have built a flow that works the following:
1. Microsoft Form to submit, possibility to upload attachments to the form
2. Attachments saved on sharepoint
3. mail sent with attachments and a pdf of the Microsoft Form submitted
 
The flow works perfectly fine except one item: from the email we cannot open the attachments. See attached file of the 'error message'. 
 
Please find also attached a screenshot of the flow.
 
Thank you for your feedback!
 
error message.jpg
Flow Screenshot.jpg
Categories:
I have the same question (0)
  • Suggested answer
    Ninjasabi Profile Picture
    122 on at

    To resolve the issue where the error says the file extension is not valid, you can use a Compose step in Power Automate to ensure that the file name includes the correct extension before attaching it to the email. Here's how you can troubleshoot and fix this issue:


    Step-by-Step Solution

    1. Verify and Retrieve the File Extension

    • Add a Compose action to extract the file extension dynamically:
      • Input:
        last(split(triggerOutputs()?['body/Name'], '.'))
      • This retrieves the file extension from the original file name provided by the Microsoft Form or SharePoint.

    2. Build the Full File Name with Extension

    • Use another Compose action to construct the file name with the correct extension:
      • Input:
        concat(triggerOutputs()?['body/Name'], '.', outputs('Compose'))
      • Replace triggerOutputs()?['body/Name'] with the dynamic content for the file name.

    3. Apply the File Name in the Email Action

    • In the "Send an Email" action:
      • For Attachments Name, use the output of the Compose step (built file name with the extension).
      • For Attachments Content, use the binary output from the "Get file content" action.

    Example Flow Configuration

    1. Trigger: Microsoft Form submission.
    2. Save Files to SharePoint: Use "Apply to each" to save each uploaded file to SharePoint.
    3. Retrieve File Content: Use "Get file content" to fetch the binary data of the file.
    4. Add a Compose to Extract File Extension:
      • Use the expression to extract the file extension.
    5. Add a Compose to Build the File Name with Extension:
      • Use the expression to ensure the file name is constructed correctly.
    6. Send Email with Attachments:
      • Attach the file using the validated file name and binary content.

    4. Debugging the Issue

    To identify the problem, add a Compose action before sending the email to inspect the constructed file name and extension:

    • Add a Compose action with:
      concat(triggerOutputs()?['body/Name'], '.', outputs('Compose'))
    • Run the flow and check the output in the run history.

    Common Pitfalls and Fixes

    1. No File Extension in Original File Name:

      • Ensure the file uploaded has an extension. If not, you may need to add a default extension based on the file type (e.g., .pdf, .xlsx).
        if(equals(outputs('Compose'), ''), 'defaultExtension', outputs('Compose'))
    2. Invalid Characters in File Name:

      • Replace invalid characters in file names:
        replace(triggerOutputs()?['body/Name'], ' ', '_')

    Final Steps

    1. Test the flow with various file uploads to confirm the extension is always valid.
    2. If the issue persists, inspect the output of each step in the run history, particularly the Compose steps, to ensure the file name is constructed correctly.

    Let me know if you need further assistance! 😊

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 251 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 239

#3
Expiscornovus Profile Picture

Expiscornovus 220 Most Valuable Professional

Last 30 days Overall leaderboard