web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Send email with existi...
Power Apps
Answered

Send email with existing attachment from attachmentcard in form

(0) ShareShare
ReportReport
Posted on by 187

Hi all,

 

I have the following scenario: A user uploads a new shipping voyage in my powerapp and is required to upload at least one attachment.

In the gallery, which shows all voyages which were uploaded, I can select an item from the gallery and view it. I have a screen called View Attachments which looks as follows.
Screenshot 2021-05-16 at 20.02.06.png

 

It contains a form and the form connects to my sharepoint list and the only datacard I show is the attachments datacard which will then show the current attachment for the selected gallery item.

What I would like the Button to do is that on select, it will send the attachment currently linked to this gallery item. I have tried the following code but the only thing it does is send an email without attachments:

Office365Outlook.SendEmailV2("fake@emailaddress","Attachment Test","Please see attachments ", {Attachtments: AddColumns( RenameColumns(ThisItem.Attachments,"Value","ContentBytes"),"@odata.type","")})

I have created a button to store the current attachment in a collection to view the current collection items and it shows the following:
Screenshot 2021-05-16 at 20.07.23.png

 

I have watched the youtube movie from Shane Young on how to do it and there are 2 differences:
1: I have an existing attachment form card so I did not copy it, put it outside of form and then have the user attach attachments  manually before the email is sent. I want to use the existing attachment(s) as stored in my Sharepoint list for this specific record.
2: In my example the Value refers to appres://datasources/Voyages/table etc. while I see in the video from Shane but also others it refers to blob after the datasources.

Can anyone help figuring out what I am doing wrong? Many thanks in advance.

Categories:
I have the same question (0)
  • timl Profile Picture
    36,415 Super User 2025 Season 2 on at

    Hi @debarbanson 

    If you're using the attachments control from an existing card, you should just be able to send your email with syntax that looks like this:

    Office365Outlook.SendEmailV2(
     "fake@emailaddress",
     "Attachment Test",
     "Please see attachments ",
     {Attachtments: RenameColumns(
     ThisItem.Attachments,
     "Value",
     "ContentBytes",
     "DisplayName",
     "Name"
     )
     }
    )

     

    I have a post here with example syntax on sending emails with attachments.

    http://powerappsguide.com/blog/post/sending-email-attachments-with-office-365-outllok

     

     

  • debarbanson Profile Picture
    187 on at

    Hi Timl,

     

    Many thanks for this. I adjusted the code as you set out, however result is the same, only getting an email without any attachments. Could this have anything to do with the Value not being a blob item? Or is the Value that I see in my collection the common one for Sharepoint list records? 

  • timl Profile Picture
    36,415 Super User 2025 Season 2 on at

    Hi @debarbanson 

    I've just been able to recreate this issue. It's strange because that syntax definitely did work until now. I think that something must have very recently changed.

    Another interesting thing is that in my test, the Mail connector (rather than the Office365Outlook connector) was able to pick up an attachment and to send it successfully, using the following code:

    Mail.SendEmailV3("tim@email.com", 
     "Enter the email title here", 
     "Enter your email message here",
     false,
     {
     files:First(ThisItem.Attachments).Value,
     filenames:First(ThisItem.Attachments).DisplayName
     }
    )

     On this basis and because this used to work, I'm not convinced that this is because value is an 'appres' item, rather than a blob item.

    Unfortunately, I'm not sure what else to suggest, maybe someone else here might have some further insight? Alternatively, it might be worth raising a support ticket with Microsoft as this is not expected behaviour.

     

  • debarbanson Profile Picture
    187 on at

    Many thanks for recreating the issue @timl , I will raise a ticket with Microsoft and see what they get back with and let you all know.

  • timl Profile Picture
    36,415 Super User 2025 Season 2 on at

    Thanks @debarbanson - let us know how you get on!

  • debarbanson Profile Picture
    187 on at

    Hi @timl and others, this is the reply from Microsoft:

    From the issue description, I understand that the function to use Office365Outlook.SendEmailV2 is not working to include attachments.
     
    The files are stored in your Sharepoint list, and you want to attach them within the email body in your app, I afraid that there is no way to achieve your needs in PowerApps currently.
     
    Currently, within PowerApps, there is no way or functions supported to get the file content of the files stored in a SharePoint . As an alternative solution, I think the combination of PowerApps and MS Flow could achieve your needs.
     
    Please refer to the solution provided in this article.
     
     
    So I guess I'll have to start looking into flow, unless someone knows of a different workaround 🙂
  • Verified answer
    timl Profile Picture
    36,415 Super User 2025 Season 2 on at

    Hi @debarbanson 

    Many thanks for this update. To be honest, I'm a bit disappointed with this response from Microsoft, given that this is something that definitely worked before, but no longer works now.

    Also, the statement beneath this factually incorrect, as it's possible to retrieve the file content of files stored in SharePoint when we send emails using the same technique, but using the Mail connector rather than the Office365Outlook connector.

    >> there is no way or functions supported to get the file content of the files stored in a SharePoint

     

    I've added a post in the ideas forum, and I would encourage anyone that encounters this problem, to vote for the issue beneath.

    https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Fix-bug-Sending-email-messages-with-the-Office365Outlook/idi-p/925808#M33655

     

  • RvdHeijden Profile Picture
    602 on at

    It's been almost a year but I haven't seen any updates yet and the problem is still there. At least im reading this post now and copied the formula with the exact same result as before.
    It does send the mail with the text but without the attachement

  • nguyenhai Profile Picture
    14 on at

    Matthew Devaney has the solution to this on his website @ https://www.matthewdevaney.com/power-apps-send-email-using-outlook-the-complete-guide/

     

    The code is below

    Office365Outlook.SendEmailV2(
     txt_EmailTo.Text,
     txt_Subject.Text,
     txt_Body.Text,
     {
     Attachments: ForAll(
     att_Attachments.Attachments,
     {
     ContentBytes: Value,
     Name: Name
     }
     )
     }
    );

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard