PowerApps Email Attachment Control – How to Use

In this PowerApps tutorial, We will discuss what is Attachments control in PowerApps, What are the important Powerapps Attachment Control properties and all the Powerapps Attachment Limits.

Also, by taking a simple scenario, We will see these below things that are related to Powerapps Attachment Control as:

  • How to add attachment control in Powerapps
  • Use of PowerApps Email Attachments with the office 365 connector
  • How to use Powerapps Attachment Control Collection
  • Powerapps patch attachments
  • What is Custom attachment control in Powerapps
  • Powerapps add an attachment to SharePoint list or Powerapps upload attachment to SharePoint
  • Powerapps clear attachment control

Powerapps Attachment Control

Powerapps Attachment Control is a type of control that helps to users to upload and delete the files from the SharePoint list or a Common Data Service entity.

Also, this control allows the users to download and open any files from their device.

Powerapps Attachment Control Properties

Below represents some important and useful Powerapps Attachment Control properties as:

  • Items: This property specifies the files that can be downloaded.
  • MaxAttachments: The control will accept the maximum number of files.
  • MaxAttachmentSize: Currently, the maximum attachment file size limit is 10 MB.
  • OnAddFile: When a user adds a new file attachment, it specifies how the app responds.
  • OnRemoveFile: When a user deletes an existing attachment, it specifies how the app responds.
  • OnUndoRemoveFile: When a user restores a deleted attachment, it specifies how the app responds.
  • AddAttachmentText: This property specifies the label text for the link used to add a new attachment.
  • DisplayMode: It specifies whether the control allows adding and deleting files (Edit), only displays data (View), or is disabled (Disabled).
  • MaxAttachmentsText: When the control contains the maximum number of files allowed, the text that replaces the “Attach file” link.
  • NoAttachmentsText: If there are no files attached in the attachment control, then an informational text shown to the user.
  • TabIndex: It specifies the Keyboard navigation order in related to other controls.
  • Visible: This property specifies whether the attachment control is visible or hidden.

Powerapps Attachment Limit

There are certain limitations present while a user is working with the Powerapps Attachment Control. Such as:

  • In the Powerapps Attachment control, you can upload the files up to 10 MB or smaller. Otherwise, If the file size exceeds 10 MB, then the control will not take the specific file.
  • Powerapps Attachments are only supported by the Common Data Service entities and SharePoint lists.
  • When the Powerapps Attachment control is in Edit mode and not inside a form, then it appears disabled. The Upload and Delete functionality works only inside a form. The app user must save the form to save the file additions and deletions.
  • Powerapps Attachment Control is not available in the Powerapps Insert tab. It only appears in the form when the Attachment form field is enabled in a SharePoint or Common Data Service form.

Add Attachment Control in Powerapps

To add the Attachment Control in Powerapps, follow the below steps that we need to do:

  • Sign in the PowerApps app with your credentials.
  • Create a blank new Canvas app and choose any one Layout either Tablet or Phone.
  • On the Powerapps Blank screen, Add a Powerapps Form (Either Edit or Display form) and connect the SharePoint list data source.
  • Select the Edit or Display form -> Select the Data Source in the Properties tab in the options panel from the Right -> Select the SharePoint Site -> Choose SharePoint List that you want to connect -> Click on Connect button.
  • Select Edit fields in the Fields section -> Click on the + Add field.
  • Select the Attachments field and select Add.
Powerapps Attachment Control
  • The Attachments field or control is only available with the SharePoint list that will appear in the form as you can see in the below screenshot.
Add Attachment Control in Powerapps

PowerApps Email Attachments with the office 365 connector

Suppose in your organization, you want to send a single or multiple Email attachment files to any user. In this case, you can use the Powerapps Office 365 Connector. See this below screenshot for your reference:

PowerApps Email Attachments with the office 365 connector

Follow these below steps to work with the PowerApps Email Attachments with the office 365 connector.

On the Powerapps screen, Add these below input controls as:

  1. To:
  • Add one Label and set its Text property as “To:”.
  • Insert a Combo box (Insert -> Input -> Combo box) and connect the Data source with Office365Users connectors.
  • Select the Combo box and set its Items property as:
Items = Office365Users.SearchUser({searchTerm:ComboBox1.SearchText,top:10})

Where,

ComboBox1 = Combo box control name

NOTE:

If you want to know more details about the Powerapps Combo box and Office 365 Users Connector, then follow this link: Create People Picker in PowerApps with Combo Box

2. Email Subject:

  • Add one Label and set its Text property as Email Subject:.
  • Insert one Text input control and set its Default property as blank.

3. Email Body:

  • Add one Label and set its Text property as Email Body:.
  • Insert one Text input control and set its Mode property as “TextMode.MultiLine“.
  • Select the Text input control and set its Default property as blank.

4. Attach file:

  • Add one Label and set its Text property as Attach file:.
  • Connect the SharePoint Data source connector (View -> Data Sources -> SharePoint -> Add a new or existing connection).
  • Select the SharePoint Site -> Choose any SharePoint List -> Hit on the Connect button. Then the specific SharePoint list will be added as shown below.
PowerApps Email Attachment with the office 365 connector
  • On the Powerapps screen, Insert one Edit form (Insert -> Forms -> Edit) -> Go to Properties tab -> add the SharePoint List data source (Company Info).
Use of PowerApps Email Attachments with the office 365 connector
  • When you will add the SharePoint List to the Edit form, By default an Attachment file also will add. Unlock the Attachments Data card -> Cut (Ctrl+X) and paste (Ctrl+V) the Attachment Data card outside of the Edit Form.
how to use PowerApps Email Attachments with the office 365 connector
  • Next, Remove the Edit form and rename this Attachment control to EmailAttachment.
how to use PowerApps Email Attachments

When you will move the Attachment data card to outside, then some error will appear on the data card properties as you can see in the above screenshot. Select the Attachment control and fix these below issues as:

  1. BorderColor: RGBA(89,0,0,1)
  2. Items: Just Remove it and make as Blank
  3. Tooltip: Just Remove it and make as Blank
  4. DisplayMode: DisplayMode.Edit

Next, We need to add a button where you can send an Email attachment once the user clicks on it.

  • Connect the Data source as Office 365 outlook (View -> Data sources -> Office365Outlook)
  • Insert a Button (Insert -> Button) and set its Text property as “Send an Email“.
  • Select the Send an Email button and set its OnSelect property as:

Where,

OnSelect = Office365Outlook.SendEmailV2(
    ComboBox1.Selected.Mail,
    txtEmailSubject.Text,
    txtEmailBody.Text,
    {
        Attachments: AddColumns(
            RenameColumns(
                EmailAttachment.Attachments,
                "Value",
                "ContentBytes"
            ),
            "@odata.type",
            ""
        )
    }
)
  • Office365Outlook.SendEmailV2 = It is a Powerapps connector that helps to send an Email via Office365Outlook.
  • ComboBox1.Selected.Mail = It specifies to whom you want to send the Attachment email. ComboBox1 is the name of the Combo box control.
  • txtEmailSubject.Text = txtEmailSubject represents the Email subject input control name and it specifies what the subject line you want to send to the user via Email.
  • txtEmailBody.Text = txtEmailBody represents the Email body input control name and it specifies what the body part you want to send to the user.
  • Attachments = It helps to store the attachment files
  • AddColumns = It helps to add the columns
  • RenameColumns = It helps to rename the columns
  • EmailAttachment.Attachments = EmailAttachment represents the Attachment control name
  • Value = Here, we need to pass the Name and Value column. So the Rename column is going to take an existing column and rename it.
  • ContentBytes = Also, it is expecting a Value column i.e. Content Bytes. So renamed as it “Value” and made it as “ContentBytes”.
  • @odata.type = It is the data type and make it as blank.

Once you will hover these formula in the formula bar, then you will see a Table where it contains the Name, ContentBytes and @odata.type as shown in below:

how to use powerapps attachment control

Preview the App and Test with Attachment Control

Preview (F5) the Attachment file app. Specify the To field, Email Subject field, Email Body field value.

Attach some files from your desktop by using the Attach file option. You can attach only those files whose size limit is 10 MB. Click on the Send an Email button as shown below.

Powerapps Attachments Control

Now the specific user (Preeti) will get the Powerapps Email attachments as like the below screenshot.

Powerapps Email Attachments

Powerapps Attachment Control Collection

Suppose you want to store the Powerapps Attachment files in the Powerapps Collections. Then you need to do these below things as:

  • Add a Button and set its Text property to “Collect Attachment Files“.
  • Select the Button and apply this below formula on its OnSelect property as:
OnSelect = ClearCollect(attachmentFiles,EmailAttachment.Attachments)

Where,

  • ClearCollect = This function helps to create a Powerapps collection where always it clears the previous value and stores the new one
  • attachmentFiles = Collection Name
  • EmailAttachment = Attachment control name
Powerapps Attachment Control Collection

Next, Preview (F5) the app and Attach one or multiple files from the system. Click on the Collect Attachment Files button.

Powerapps Attachment Collection

Open the Powerapps Collections (View -> Collections) and click on the Collection name (AttachmentFiles). You can view the Powerapps attachment files as shown below.

Powerapps Attachment control Collections

Powerapps patch attachments

Here by taking a simple scenario, I will explain you how to use the Powerapps Patch attachments.

If you want to add an attachment to a SharePoint List using Powerapps Patch function, then this is known as PowerApps Patch Attachments.

  • As there is no way to add the Powerapps Attachment control directly in the Powerapps screen, So we need to add a Powerapps Form (Either Edit or Display Form).
  • Next, Connect the SharePoint Data source and choose your specific SharePoint list where you want to add the Attachments.
  • Go to Edit fields from the Fields section. Add the Attachment field (By default, this attachment control has been added automatically).
Powerapps patch attachment control
  • Insert a Button in the form and set its Text property to Submit.
  • Select the Submit Button and apply this below formula on its OnSelect property as:
OnSelect = Patch(
    'Company Info',
    Defaults('Company Info'),
    {
        Title: DataCardValue1.Text,
        Attachments: DataCardValue3.Attachments
    };
    Form1.Updates
)

Where,

  • Patch = Patch function is used to modify single or multiple records of a data source
  • ‘Company Info’ = SharePoint List Name
  • Defaults(‘Company Info’) = Defaults function helps to create a new item or record in the SharePoint list (Company Info)
  • Title:DataCardValue1.Text = Title represents the SharePoint List column name and the DataCardValue1 represents the Title input field name
  • Attachments: DataCardValue3.Attachments = Attachments represents the SharePoint List column name where the files will save and the DataCardValue3 represents the Attachment control name
  • Form1.Updates = Form1 is the Edit form name that will update

Refer this below screenshot:

Powerapps patch attachments
  • Preview (F5) the app. Click on Attach file from the Attachment control and select one or multiple files from your system.
  • Enter Company Name (just renamed the Title column) and hit the Submit button.
patch attachments in Powerapps
  • Next, go to the SharePoint list (Company Info) and refresh it. You can see the new item has been added to that list.
  • When you will open the item Details Pane, then you can view all the Powerapps Attachment files that you have inserted as shown below:
Power apps patch attachments

Custom attachment control in Powerapps

Powerapps Attachment Control is a powerful hidden control because we know that we can get this control inside a Powerapps Edit form or a Display form. There is no input Attachment control available in the Powerapps Insert tab.

So if you want to view the Attachment File name and Attachment File Content, then we need to do these below things as:

  • On the Powerapps screen, Insert one Label control and set its Text property as:
Text = First(EmailAttachment.Attachments).Name

Where,

EmailAttachment = Attachment Control Name

  • Insert one Image control (Insert -> Media -> Image) and set its Image property as:
Image = First(EmailAttachment.Attachments).Value
  • Preview (F5) the app. Add a file (suppose an Image file) to the Attachment control. In the Label control, you will see the Attachment File name. Similarly, In the Image control, you will see the Attachment File content as shown below.
Custom attachment control in Powerapps

Powerapps add an attachment to SharePoint list

You can easily add single or multiple attachment files to a SharePoint list or library. As we discussed above, the Powerapps Attachment control only appears inside the Edit or Display Form.

So to add the Powerapps attachment files in a SharePoint List, We need to do very simple things as:

  • Connect the SharePoint Data source connector (View -> Data Sources -> SharePoint -> Add a new or existing connection).
  • Select the SharePoint Site -> Choose any SharePoint List -> Hit on the Connect button. Then the specific SharePoint list will be added.
  • Insert one Edit form (Insert -> Forms -> Edit) -> Go to Properties tab -> add the SharePoint List data source (Company Info).
  • You can see, By default, an Attachment file has been added in the Powerapps Edit form. So you do not need to do anything for the attachment. Just unlock it.
  • Insert one Button and set its Text property to “Submit Record in SharePoint List“.
  • Select the button and set its OnSelect property as:
OnSelect = SubmitForm(Form1);

Where,

Form1 = Edit form name

Next, Preview the app and add some attachments to the Attachment control. Click on the button (Submit Recod in SharePoint List).

Powerapps add an attachment to SharePoint list

Now the new record has been added to the SharePoint List. Go to the SharePoint list (Company Info) -> Select the new item -> Click on the Details pane -> you can view all the Powerapps attachments under the Properties section as like the below screenshot.

Powerapps add attachment to SharePoint list

Powerapps clear attachment control

Most of the time you can see users are clearing or resetting the previous attachments by using the cancel icon (from the Attachment control itself). But there are some users who do not want to clear the attachments individually by using the Cancel icon.

To clear the attachments from the Attachment control, We can take a button and when a user will click on the button, then all the attachments will clear from the Attachment control. Follow these below things:

  • Insert a Button and set its text property to “Reset“.
  • Select the Reset Button and set its OnSelect property as:
OnSelect = ResetForm(Form1);NewForm(Form1)

Where,

Form1 = Edit form name

Preview the app and click on the Reset button. Then you can see all the attachment files will clear from the attachment control at a time.

Also, you may like these below Powerapps Tutorials:

In this PowerApps tutorial, We discussed what is PowerApps Attachments control, Powerapps Attachment Control properties.

Also, We saw these below things that are related to Powerapps Attachment Control as:

  • Powerapps Attachment Limitations
  • Add attachment control in Powerapps
  • PowerApps Email Attachments with the office 365 connector
  • How to use Powerapps Attachment Control Collection
  • Powerapps patch attachments
  • Custom attachment control in Powerapps
  • Powerapps add an attachment to SharePoint list or Powerapps upload attachment to SharePoint
  • Powerapps clear attachment control
  • >