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 Automate / Flow to send mail with...
Power Automate
Unanswered

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!
 
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

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 Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard