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 / Saving email attachmen...
Power Automate
Suggested Answer

Saving email attachment to SharePoint

(0) ShareShare
ReportReport
Posted on by 1
PLEASE NOTE: the original "When a New Email Arrives in a Shared Mailbox" routine is no longer available in the latest version of PAD, which renders all of the tutorials online for my question void.
 
I am trying to grab emails from a mailbox, and then save both the email content & its attachments to SharePoint.  Saving the email portion is working great...it's the attachment piece I'm struggling with.
 
Looping through the attachments of the email using a for-each loop, I use the "Get Attachment (V2)" routine to grab them all, and then a "Create File" routine to try and write the content of the attachments out to SharePoint.  However, I get an error re: "Argument 'File Content' must be 'Binary'.  No matter what variable selection I try, and what I assume is the binary content of the attachment, the flow won't run.
 
Do I need to physically save the attachment somewhere, convert it to binary, and then upload it to SharePoint, so should this all be able to happen "in memory"?  If so, any idea what I'm doing wrong?
I have the same question (0)
  • WillPage Profile Picture
    2,323 Super User 2026 Season 1 on at
    Why are you using Power Automate Desktop for something that would be much easier to do in a cloud flow?
  • Suggested answer
    Nitesh Shrivastava Profile Picture
    23 on at
    You can use the ‘contentBytes’ for the attachment property in the ‘File Content’ section of ‘Create File’ action.
    I tried below options and it worked:
    1. Action #1: Used “Get Emails (V3)” action to get the email.
      1. Set “Include Attachments” as “Yes”
      2. Select Search Query option as required to filter the emails.
    2. Action #2: You can run a loop ‘Apply to each’ for the received emails for the following action: outputs(‘Get_Emails_(V3)’)?[‘body/value’]
    3. Action #3: Create a nested loop ’Apply to each 2’ for the attachments in the email -item(‘Apply_to_each’)?[‘attachments’]
    4. Action #4: In the nested loop use “Create File” Action to upload attachments to SharePoint:
    In the “File Content” section select: item(‘Apply_to_each_2’)?[‘contentBytes’’]
    You can select “Site Address”, “Folder Path” and “file Name” as required.
    During my test, I was able to upload file in SharePoint Library successfully.
     
    If I have answered your question, please mark it as the preferred solution . If you like my response, please give it a Thumbs Up 👍.
     
    Thanks and Regards,
    Nitesh Shrivastava
  • Suggested answer
    Riyaz_riz11 Profile Picture
    4,048 Super User 2026 Season 1 on at
    Hi,
     

    1. Use "Get Attachment (V2)" to get the attachment content.

    • The output you get is usually Base64-encoded string (check what your output variable looks like — if it’s a long string with letters/numbers like U29tZSBiYXNlNjQgZW5jb2RlZCBkYXRh..., it’s Base64).

    2. Convert Base64 string to binary

    • In Power Automate (cloud flows), there's an expression base64ToBinary().

    • In Power Automate Desktop, to convert a Base64 string to binary content, you should use the "Convert text to binary" action:

      • Input: Your Base64 string (the attachment content)

      • Encoding: Base64

      • Output: Variable holding the binary content  

    3. Pass the binary output to the "Create File" action

    • Use the variable containing the binary content as the "File Content" input in the SharePoint "Create File" step.

    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz

  • JS-17102058-0 Profile Picture
    2 on at
    I have an existing shared mailbox containing 4 years' worth of emails, many of which include attachments. My goal is to create a Power Automate flow that extracts each attachment and saves it to a SharePoint folder.
    I've already made several attempts to build this flow, but unfortunately, I haven’t been successful.
    Could anyone help me with this? 

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard