cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Email with attachment

Hi,

 

I need some help.Smiley Sad

 

How can i add file attachments so I can email it via a button (OnSelect) in my form.

DataCardValue16 is a Attachment field. 

 

I did something like this, but it is not the correct code...

 

Office365.SendEmail("abc@def.com","Subject","EmailBody",{Attachments:Table(DataCardValue16.Attachments,"Value","FileContent"})

 

Thanks for the help.

Adam

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@Anonymoushere is the dilema.

When you are dealing with a datacard attachment object, it is missing some of the pieces that it needs to get back to the data.  Keep in mind, when you send email like this, PowerApps has to download the content bytes from the SharePoint and then attach.  

I'll say up-front - if you want to skip the download to send (which could pause your App for a long time depending on the size of the attachments) then look to Flow.  You can easily get content bytes and add multiple attachments through Flow - and it's much faster as you're not limited by the bandwidth of your device you're running PowerApps on. 

 

Now with that said - You can't use the DataCard.Attachments - it is missing key columns needed to get to the data.  You can't use the Form.Updates.Attachments - it is empty (unless you're adding attachments and they've not been submitted).

 

SO - you need to go back to the source.  Let's say your form is getting its Item from a Gallery1.  Typical Item for your form would be Gallery1.Selected.

Ok - so, in this case we CAN go back to the Gallery and we WILL have the information necessary to complete the next step.

AND THAT IS - 

   Office365.SendEmail("abc@def.com","Subject","EmailBody",
{Attachments:AddColumns(Gallery1.Selected.Attachments, "Name", DisplayName, "ContentBytes", Value, "@odata.type", "")})

 

This will take the source list of attachments (with all its needed info for getting to attachments) and it will add the necessary columns for the Attachments parameter of the SendEmail function.

End result, you will get an email sent with all the attachments that are in the attachments collection.

 

HOWEVER...again, this is a hit from performance as your PowerApp will need to pump down the data in order to attach - still better through Flow.

 

Hope this helps some.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

6 REPLIES 6
RandyHayes
Super User III
Super User III

@Anonymoushere is the dilema.

When you are dealing with a datacard attachment object, it is missing some of the pieces that it needs to get back to the data.  Keep in mind, when you send email like this, PowerApps has to download the content bytes from the SharePoint and then attach.  

I'll say up-front - if you want to skip the download to send (which could pause your App for a long time depending on the size of the attachments) then look to Flow.  You can easily get content bytes and add multiple attachments through Flow - and it's much faster as you're not limited by the bandwidth of your device you're running PowerApps on. 

 

Now with that said - You can't use the DataCard.Attachments - it is missing key columns needed to get to the data.  You can't use the Form.Updates.Attachments - it is empty (unless you're adding attachments and they've not been submitted).

 

SO - you need to go back to the source.  Let's say your form is getting its Item from a Gallery1.  Typical Item for your form would be Gallery1.Selected.

Ok - so, in this case we CAN go back to the Gallery and we WILL have the information necessary to complete the next step.

AND THAT IS - 

   Office365.SendEmail("abc@def.com","Subject","EmailBody",
{Attachments:AddColumns(Gallery1.Selected.Attachments, "Name", DisplayName, "ContentBytes", Value, "@odata.type", "")})

 

This will take the source list of attachments (with all its needed info for getting to attachments) and it will add the necessary columns for the Attachments parameter of the SendEmail function.

End result, you will get an email sent with all the attachments that are in the attachments collection.

 

HOWEVER...again, this is a hit from performance as your PowerApp will need to pump down the data in order to attach - still better through Flow.

 

Hope this helps some.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Anonymous
Not applicable

Hi Randy,

 

Thanks for the info. I will do some research doing it via a flow.

Many thanks for putting me in the right direction.

 

Regards,

Adam

Hi there,

Could you please explain how you take the attachments from the attachments datacard and put them into a gallery?

Flow scares me, so before I try and learn that (still picking up the PowerApps basics) I’d like to see how the performance is affected in PowerApps.

@d3ell 

Don't let Flow get you scared...it can be a good friend once you get the hang of it.

 

If you are looking to have attachments listed in a Gallery, you just need to set your Items for your Gallery to the (assuming you have another Gallery of the actual records) YourGalleryOfRecords.Selected.Attachments

 

This will give you a Gallery of them as you select on another Gallery.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Anonymous
Not applicable

Thanks for this explanation. Is it possible to use a similar expression to send only specific items that have been attached to a SharePoint list item (selected from gallery) as an email attachment or would you use Flow for that?

@Anonymous 

I would still consider using Flow for that as it has a bit better ability to get content and in the right format.  But it really depends on what you are designing for.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (71,175)