Skip to main content

Notifications

Power Automate - General Discussion
Answered

How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

(1) ShareShare
ReportReport
Posted on by 930

I have a specific requirement and need some guidance. I'd like to set up a flow in Power Automate that does the following:

  1. Monitors my inbox for emails with the subject line "Monthly Finance Data".
  2. If such an email has an Excel attachment, I want the attachment to be automatically saved to a specific location in my OneDrive.
  3. After saving the attachment, I'd like this action to trigger a refresh of a particular dataset in Power BI.

Has anyone implemented something similar or can provide steps or resources that can guide me in setting this up?. 

 

Thanks in advance for your help!

  • Verified answer
    HamidBee Profile Picture
    HamidBee 930 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    Okay so I managed to get the flow to run successfully. For the action "Create file" I set the following settings:

    File Name: Attachments Name
    File Content: Attachments Content

  • HamidBee Profile Picture
    HamidBee 930 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    Sure. Hers is the output from the "Create file":

    {"statusCode":414,"headers":{"Cache-Control":"no-cache","Pragma":"no-cache","Transfer-Encoding":"chunked","x-ms-request-id":"06be5fc6-0fce-42a1-a00a-67b30376a04b","X-AspNet-Version":"4.0.30319","X-Powered-By":"ASP.NET","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","x-ms-apihub-obo":"false","Date":"Fri, 03 Nov 2023 18:06:36 GMT","Content-Type":"application/json","Expires":"-1"},"body":{"status":414,"message":"Request-URI Too Long - <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"http://www.w3.org/TR/html4/strict.dtd\">\r\n<HTML><HEAD><TITLE>Request URL Too Long</TITLE>\r\n<META HTTP-EQUIV=\"Content-Type\" Content=\"text/html; charset=us-ascii\"></HEAD>\r\n<BODY><h2>Request URL Too Long</h2>\r\n<hr><p>HTTP Error 414. The request URL is too long.</p>\r\n</BODY></HTML>\r\n","source":"api.connectorp.svc.ms"}}
     
     
  • trice602 Profile Picture
    trice602 11,840 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    Hi @HamidBee ,

     

    Please look at your output of create file and look at the path.  What does it say?

     

        "body": {
            "Id""b!c-eQ6V7Dm0mLW7e5hrm6-YjXYGqIH39GtO407tayRriMdclbe36MQLBfuaNjicOD.01AJ5LOPNEBUIJ7CLYTZAINIVCLOYR3PBI",
            "Name""SampleSalesData.xlsx",
            "NameNoExt""SampleSalesData",
            "DisplayName""SampleSalesData.xlsx",
            "Path": "/OneDriveFiles/SampleSalesData.xlsx",
     
    Next, let's check all the values:
     
    1)  trice602_0-1699035595424.png

     

    2) 

    trice602_1-1699035627765.png

     

    3) 

    trice602_2-1699035654818.png

     

    Sorry, I've been unable to duplicate to error.

     

     

  • HamidBee Profile Picture
    HamidBee 930 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    Here are the screenshots:

    pic1.png

    pic2.png

    pic3.png

  • trice602 Profile Picture
    trice602 11,840 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    Hi @HamidBee ,

     

    I didn't get any errors.  Can you please share your expanded flow actions?  Here's my results (I've removed the Power BI refresh action for this test):

     

    trice602_0-1699034298010.png

     

    trice602_1-1699034352514.png

     

     

    My hunch is your create file name dynamic content.  Please share.

     

     

  • trice602 Profile Picture
    trice602 11,840 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    I will test over here.

  • HamidBee Profile Picture
    HamidBee 930 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    Yeah sure. When I tested the flow I sent an email to myself with the document attached. The document name is called "SampleSalesData.xlsx" and the subject line is "Monthly Finance Data".

  • trice602 Profile Picture
    trice602 11,840 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    Hi @HamidBee ,

     

    I don't think the folder name is the issue, I also created and saved here.  The issue most likely is the file name length.  Can you share what the file name is please?  I'm guessing the file name is long?

     

    trice602_1-1699033783856.png

     

     

  • HamidBee Profile Picture
    HamidBee 930 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    Thanks for getting back to me. I have built the flow using your suggesting and tried testing it unfortunately I'm getting an error when trying to create a file in OneDrive. Here is the error message:

    Request-URI Too Long - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <HTML><HEAD><TITLE>Request URL Too Long</TITLE>
    <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
    <BODY><h2>Request URL Too Long</h2>
    <hr><p>HTTP Error 414. The request URL is too long.</p>
    </BODY></HTML>

     

    I am trying to save the Excel file in a OneDrive folder I have called "OneDriveFiles". So I set the folder path to:

    /OneDriveFiles

    Any advice would be greatly appreciated. Thanks in advance. 

  • trice602 Profile Picture
    trice602 11,840 on at
    Re: How to Automate Saving Email Attachments to OneDrive and Refresh Power BI Dataset?

    Hi @HamidBee ,

     

    I think this will work for you, please let me know.

     

    trice602_0-1699029864453.png

     

    Next apply to each (in case there is more than one attachment).  Dynamic content is attachment name and attachment content bytes - fyi

     

    trice602_1-1699029912436.png

     

    Last step, I refresh a desired dataset.

     

    trice602_2-1699029974054.png

     

    Here's the entire flow.

     

    trice602_3-1699030035451.png

     

     

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,526

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard