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 / How to send a email wi...
Power Apps
Answered

How to send a email with patched contents

(0) ShareShare
ReportReport
Posted on by 84

Hi, 

 

I made a form in powerapps, when i hit on send button in the app the contents will be send to a sp list. Now i'm looking for a way to sending it also to my email. Is there a way to do that in the same code? I'm using this code on the 'on select': 

 

ForAll(Gallery1.AllItems;
 Patch(Uitgeleend;
 Defaults(Uitgeleend); 
 {Title:Titel; 
 categorie:Categorie.Value;
 barcode:Barcode;
 project:Textcart.Text;
 datumretour:Datepick.SelectedDate; 
 aantal: Value (quant.Text)
 }
 )
)

;;Clear(MyCollection)
;;Navigate(Uitleen)

 Thanks! 

Categories:
I have the same question (0)
  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    hi @MelvinGRM yes you can do that, if you want to send an email for every record do the following:

    Add the Office365Outlook connector

    Alter code as follows

    ForAll(Gallery1.AllItems;
     Patch(Uitgeleend;
     Defaults(Uitgeleend); 
     {Title:Titel; 
     categorie:Categorie.Value;
     barcode:Barcode;
     project:Textcart.Text;
     datumretour:Datepick.SelectedDate; 
     aantal: Value (quant.Text)
     }
     );
     Office365Outlook.SendEmailV2(
     "your Email",
     "your Subject",
     Title:Titel 
     categorie:Categorie.Value
     barcode:Barcode
     project:Textcart.Text
     datumretour:Datepick.SelectedDate 
     aantal: Value (quant.Text)
     )
    
    )
  • MelvinGRM Profile Picture
    84 on at

    Hi, thanks for your help! I copied the code and pasted it in the editor and it gives an error: unexpected signs. the formula contains ParenClose while Colon is expected.

     

    The code: 

     

    ForAll(Gallery1.AllItems;
     Patch(Uitgeleend;
     Defaults(Uitgeleend); 
     {Title:Titel; 
     categorie:Categorie.Value;
     barcode:Barcode;
     project:Textcart.Text;
     datumretour:Datepick.SelectedDate; 
     aantal: Value (quant.Text)
     }
     );
     Office365Outlook.SendEmailV2(
     "mymail@work.com";
     "Test";
     Title:Titel 
     categorie:Categorie.Value 
     barcode:Barcode
     project:Textcart.Text
     datumretour:Datepick.SelectedDate 
     aantal: Value (quant.Text)
     )
    
    )
    
    ;;Clear(MyCollection)
    ;;Navigate(Uitleen)

     What did i wrong? Thanks! 

  • Verified answer
    WarrenBelz Profile Picture
    155,752 Most Valuable Professional on at

    Hi @MelvinGRM ,

    Two things - firstly the Patch will work a lot faster if done as below. Also the Body of the email needs to be a Text String - I have added line breaks as well

    Patch(
     Uitgeleend;
     ForAll(
     Gallery1.AllItems;
     {
     Title: Titel; 
     categorie: Categorie.Value;
     barcode: Barcode;
     project: Textcart.Text;
     datumretour:Datepick.SelectedDate; 
     aantal: Value(quant.Text)
     }
     )
    );
    ForAll(
     Gallery1.AllItems;
     Office365Outlook.SendEmailV2(
     "mymail@work.com";
     "Test";
     "Title:" & Titel &
     "<br>categorie:" & Categorie.Value & 
     "<br>barcode:" & Barcode &
     "<br>project:" & Textcart.Text & 
     "<br>datumretour:" & Text(Datepick.SelectedDate, "dd/mm/yyyy") & 
     "<br>aantal:" & quant.Text & "<br>"
     )
     )
    );;
    Clear(MyCollection);;
    Navigate(Uitleen)

     

    Please click Accept as solution 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 Thumbs Up.

    Visit my blog Practical Power Apps

  • MelvinGRM Profile Picture
    84 on at

    Hi @WarrenBelz thanks for the code and your tip for patching. 

     

    When i use your code it gives an error: invalid argument type (table) a record value is expected instead

     

    What did i wrong? 

    thanks! 

     

    error.png
  • WarrenBelz Profile Picture
    155,752 Most Valuable Professional on at

    Hi @MelvinGRM ,

    I simply used your code assuming it had valid values - my only change was the ForAll/Patch reversal (for speed) and the text structure in the body of the email. Which element is causing the error ?

  • MelvinGRM Profile Picture
    84 on at

    Hi @WarrenBelz

     

    i changed the patch code back and it works. Thanks! 
    The code that i use: 

     

    ForAll(Gallery1.AllItems;
     Patch(Uitgeleend;
     Defaults(Uitgeleend); 
     {Title:Titel; 
     categorie:Categorie.Value;
     barcode:Barcode;
     project:Textcart.Text;
     datumretour:Datepick.SelectedDate; 
     aantal: Value (quant.Text)
     }
     );;
    ForAll(
     Gallery1.AllItems;
     Office365Outlook.SendEmailV2(
     "mail@mail.com";
     "Test";
     "Title:" & Titel &
     "<br>categorie:" & categorie.Value & 
     "<br>barcode:" & barcode &
     "<br>project:" & Textcart.Text & 
     "<br>datumretour:" & Text(Datepick.SelectedDate; "dd/mm/yyyy") & 
     "<br>aantal:" & quant.Text & "<br>"
     )
    )
    );;
    Clear(MyCollection);;
    Navigate(Uitleen)

     

    If i patch two or more items in one gallery, i get separated emails. Is there a way to send al those information in one email? 

     

    Thanks!

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 483

#2
WarrenBelz Profile Picture

WarrenBelz 399 Most Valuable Professional

#3
11manish Profile Picture

11manish 327

Last 30 days Overall leaderboard