cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MelvinGRM
Helper II
Helper II

How to send a email with patched contents

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! 

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6
rubin_boer
Super User
Super User

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)
    )

)

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! 

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

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! 

 

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 ?

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!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,300)