Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Answered

Send E-mail with attachments from sharepoint list

(1) ShareShare
ReportReport
Posted on by 88
Dear Power Apps community

I'm trying to send an e-mail from powerapps, with in the attachments a file from a sharepoint list.
This is to make it possible for employees to send certain documents to their email address from a local computer on the production site.

(note: i'm Dutch, so names of documents, buttons and so on could sometimes be in the dutch language, but i work in the englisch version of powerapps)

I have a gallery called Galerij_Documenten
Items value is InfoKioskInteressanteDocs (a sharepoint list)
This Sharepoint list has a couple of columns:
- LblSoortDocTitel with item ThisItem.TitelLink
- LblWelkDocTekst with item ThisItem.'Uitleg link'
- DataCardValueDocs with item ThisItem.Attachments

Everything works fine for now.
I have a button in the gallery with the following onselect formula
Clear(Attachment);
Collect(Attachment,DataCardValueDocs.Attachments);
Office365Outlook.SendEmailV2(
    EmailadresInput.Text,
    LblSoortDocTitel.Text,
    LblWelkDocTekst.Text,
    {
        Attachments:
        RenameColumns(
            Attachment,
            "Value", "ContentBytes"
        )
    }
),

If i only do the first part of Collect(Attachments ...) i have in my collections 'Attachments (Table 2 Rows)
If i click on view table i get 2 columns
Name and Value

But i get an error on this part of the formula of the button:
RenameColumns(
            Attachment,
            "Value", "ContentBytes"
        )

The error is the following:
Missing column. Your formula is missing a column 'Attachments.ContentBytes' with a type of 'Blob'.

Is my 'renamecolumns' formule wrong?
Of what can i do to fix this type of 'Blob'?
I was working with this video as my guide:
https://www.youtube.com/watch?v=849WRw65JBo&t=1s

Thank you in advance!

​​​​​​​Greetings Miguel
  • MiguelDeNeve Profile Picture
    MiguelDeNeve 88 on at
    Send E-mail with attachments from sharepoint list
     
    I will try to link the gallery with a form when i select a row.
     
    In that form i will attach everything.
     
    Thank you for the advice :)
  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,343 on at
    Send E-mail with attachments from sharepoint list
    OK- I see the issue - I did not realise you were trying to the this inside a gallery - I assumed it was in a Form. Although what you have done technically should work, it simply does not. You need another step to open a Form with the selected record (you can hide the attachment control) and have a button to send the email.
  • MiguelDeNeve Profile Picture
    MiguelDeNeve 88 on at
    Send E-mail with attachments from sharepoint list
    Hi @WarrenBelz
     
    I also tried it out of a gallery, as you did.
    I found out that if i change the textinput to the classic it works outside of a gallery.
    If i work inside of a gallery, it keeps telling that the attachments are empty.

    It seems i am overlooking something that you did right:

  • MiguelDeNeve Profile Picture
    MiguelDeNeve 88 on at
    Send E-mail with attachments from sharepoint list
    Hello @WarrenBelz
     
    Thank you for your quick response! :)
     
    The Items of DataCardValueDocs is ThisItem.Attachments
    This way it shows in the gallery the right column contents.
     
    Am i overlooking something?
    Or do i need to change something small?
  • WarrenBelz Profile Picture
    WarrenBelz 145,343 on at
    Send E-mail with attachments from sharepoint list
    The code is correct - I use it regularly in prod apps - I constructed a model with your exact control names as below and received the email as expected
     
    The error you are getting  suggests the content is empty or invalid. What is the Items of this ?
     
  • MiguelDeNeve Profile Picture
    MiguelDeNeve 88 on at
    Send E-mail with attachments from sharepoint list
     
     
    Hi @WarrenBelz
     
    I tried your suggested answer.
    I changed the code from this
    Clear(Attachment);
    Collect(Attachment,DataCardValueDocs.Attachments);
    Office365Outlook.SendEmailV2(
        EmailadresInput.Text,
        LblSoortDocTitel.Text,
        LblWelkDocTekst.Text,
        {
            Attachments:
            RenameColumns(
                Attachment,
                "Value", "ContentBytes"
            )
        }
    ),
     
    To this 
    Office365Outlook.SendEmailV2(
       EmailadresInput.Text,
       LblSoortDocTitel.Text,
       LblWelkDocTekst.Text,
       {
          Attachments:
          RenameColumns(
             DataCardValueDocs.Attachments,
             Value,
             ContentBytes
          )
       }
    )
     
    But then i get this error:
     
     
     
     
    If i do use the whole formula, i get the following error:
    Clear(Attachment);
    Collect(Attachment,DataCardValueDocs.Attachments);
    Office365Outlook.SendEmailV2(
       EmailadresInput.Text,
       LblSoortDocTitel.Text,
       LblWelkDocTekst.Text,
       {
          Attachments:
          RenameColumns(
             DataCardValueDocs.Attachments,
             Value,
             ContentBytes
          )
       }
    )
     
    Do you maybe know how i can fix this?
    Is what i'm trying to do too dificult for powerapps to achieve?
    Or are there any alternatives?
  • Suggested answer
    WarrenBelz Profile Picture
    WarrenBelz 145,343 on at
    Send E-mail with attachments from sharepoint list
    Firstly you do not need quotes "" around RenameColumns parameters. Also you do not need the "one use" collection.
    Office365Outlook.SendEmailV2(
       EmailadresInput.Text,
       LblSoortDocTitel.Text,
       LblWelkDocTekst.Text,
       {
          Attachments:
          RenameColumns(
             DataCardValueDocs.Attachments,
             Value, 
             ContentBytes
          )
       }
    )
     
    Please click 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 giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,343

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard