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 Apps / Attachment control alw...
Power Apps
Answered

Attachment control always reset on App Refresh

(1) ShareShare
ReportReport
Posted on by 216
Hi,
 
I have a requirement to send an email to a user.  For every mail that is sent, the attachment must be sent.  
The attachment does not change.
 
The mail is sent successfully.  But when the app closes or refreshes the form attachments is reset.
The ask is how to ensure that the form is not reset and on app refresh, the form will always contain that attachment.
I have checked the Reset of the form. This is set to False.
I have created a button connected to a gallery.
All of these work for as long as the app is open.
I have also tried the SaveData to save to localcache, but this did not work either.
Any ideas would be appreciated.
 
Kind regards
 
 
Rene Voller
 
 
 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,224 Most Valuable Professional on at
    What you are experiencing is a fundamental llimitation of Power Apps SaveData - it will not store binary values (which is what an attachment is).
     
    If the attachment is always the same item, then store it in a separate list (I will call it AttachFiles here) and have one record with the file  attached and then make the Items of your Attachment Control
    First(AttachFiles).Attachments
    The file will load every time you open the app and you can then attach it to the email.
     
    Please 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 answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
     
     
  • Suggested answer
    11manish Profile Picture
    1,894 on at
    Attachments in Power Apps are not designed for static/reusable files.

    Store Attachment in SharePoint / Dataverse and Reuse

     
  • Suggested answer
    Haque Profile Picture
    2,309 on at

    Hi @RVoller,

    Probably it’s like a state persistence problem in Power Apps: attachments are stored in memory while the app is open, but they don’t survive a refresh or close unless you deliberately persist them somewhere externally.

    Saying so let's see what happens in memory with attachment control: Let's imagine we have a form with an Attachment control bound to a SharePoint list item.

    Attaching a file: Let's say for example we add a file (say Policy.pdf) into the attachment control, while the app is open. Where the file is now? It is now held in memory only — it hasn’t been saved anywhere permanent yet. We can send emails with it because the control exposes the binary content while the app session is alive.

    Refreshing the app:  If we close / refresh the app: Power Apps reloads the form from the SharePoint list. By this time attachment content was not saved to SP (or any storage), the control has nothing to show. In memory attachment conent has been erased from the app. That’s why it looks like the form “reset,” even though Reset = false. The reset property only controls whether the control clears itself when navigating, not whether unsaved attachments survive a session.

     

    Hecne your alternative solution "SaveData to save to localcache, but this did not work either" didn't get any luck.

    What I assume - when you save an instance (record) along with an attachement, the corresponding entry is beings saved in the db (any storage you are maintainint) and then an email is sent to the respective stakehodlers.

     

     If really this is the case, we have the following options: 

    1. Store the Attachment in the Data Source - Use SubmitForm(FormName) to save the attachment to SharePoint or Dataverse. Next time when the app loads, you can retrieve the file to attachment control. We cana use Media/File column in datavese. Once the file stored in any storave even in collection - we can pre-populate it (OnVisible of the screen for example) on deamnd.

    2. Alternatively, store the file in a SharePoint document library and reference its URL in your email send logic (No need to re‑attach every time).

    3. Prepopulate the form, set the attachment control's item property to a collection that contains the file reference:

    ClearCollect(colAttachment, {Name:"Policy.pdf", Value:Download("https://sharepointsite/Policy.pdf")})
    

    Note: You have to have stored the file somewhere so that you can reload them once app is closed/refereshed.

     

    References:

    0. Attachment Control in PowerApps: Limitations

    1. Bit of olde article but helpful:  SaveData and LoadData Unleashed

    2. Refresh function example

     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
     
  • RVoller Profile Picture
    216 on at
    Hi @WarrenBelz,
     
    I created a separate list as suggested, and set the items.  The email was sent correctly.  
    However, I get the following error when trying to open the attachment in Outlook.
     
     
    I checked the attachment in the list.
    The code is as follows:
    {
            Attachments: ForAll(
                att_EmailFiles.Attachments,
                {
                    Name: Name,
                    ContentBytes: Value
                }
    
    Any assistance would be appreciated.
     
    Kind regards
     
    Rene Voller
     
  • RVoller Profile Picture
    216 on at
     
     
    Although the solution works with adding the First(AttachFiles).Attachments, when the user tries to open the attachment in Outlook, then the .pdf is corrupted and cannot be opened. 
     
    If I then delete the attachment and upload the same file to the attachment control and then send it via email.  The attachment control then works and the user is able to open  the file without any errors.
     
    Any suggestions?
     
    Kind regards
     
    Rene Voller
     
     
     
  • Verified answer
    WarrenBelz Profile Picture
    155,224 Most Valuable Professional on at
    That is an interesting anomaly, but easily fixed - I tested the following here and it worked fine: -
     
    Add a Form with the DataSource 
    AttachFiles
     (if that is what you called the List) and the Item
    First(Attachfiles)
    Now add an Attachment Control and you will see your attachment appear - I assume the control will be called att_EmailFiles as before and your email for the attachment
    Office365Outlook.SendEmailV2(
       ToAddressHere,
       "SubjectHere",
       "BodyHere",
       {
          Attachments: 
          {
             Name: First(att_EmailFiles.Attachments).Name,
             ContentBytes: First(att_EmailFiles.Attachments).Value
          }
       }
    )
     
    Please 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 answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
  • Verified answer
    WarrenBelz Profile Picture
    155,224 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for. Happy to assist further if not.
     
    Please 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 answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn   
  • RVoller Profile Picture
    216 on at
     
    The solution worked liked a dream.
     
    thank you once again.
     
    Kind regards
     
    Rene Voller
     
     

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 Apps

#1
Vish WR Profile Picture

Vish WR 762

#2
11manish Profile Picture

11manish 640

#3
Valantis Profile Picture

Valantis 548

Last 30 days Overall leaderboard