Introduction
In this article, I am going to explain how to send an email on a button click event in PowerApps through Microsoft Flow.
Overview
- Create a button on the item details view screen.
- Create a flow for sending an email with parameters on PowerApps button trigger.
- Pass the required parameter values on button click in PowerApps.
- Publish the app and click the button whenever you want to send an email.
Create a PowerApp for the desired list
I have created a SampleList here with the following 2 columns and data: (When you exit Classic Experience, you will get the options like Flow, PowerApps as below).
Create an app named AppForSendEmail.
Now, click on the item’s next arrow to navigate to the detail view screen as shown in the above figure. It will take you to the below screen.
Now, add a button for sending the mail on clicking as below.
Procedure for adding a button.
- Click on Button under Insert.
- Then, name the button on text property as you want where I’m naming it as Send Mail.
The resulting screen is shown below.
Now the setup is completed in the app, let's create a flow on the button click.
Procedure
- Click on Button.
- Click on Flows under Action.
- Now the Data window appears, click on Create a new flow on it. It will take you to the Flow Studio.
Now add the Send an email action after the immediate step of PowerApps.
Build the email with the details for TO, Subject, Body, etc. as you require.
Here, we can either mention the details directly or we can pass info from power apps.
Let’s give some of these directly, and have some of them pass from PowerApps as below.
Here, the To address is given directly as my name (Mahipal Reddy); while the subject and body are passing from PowerApps with the help of Ask in PowerApps as shown above.
After saving the flow, you will get a window as shown below.
Now, add this flow to the button. Let's move to the app and add it on the click of the flow name and pass the required things within the button, as shown below.
I have passed the subject and body from the app as above.
From the picture,
- "This subject is coming from app" is the static value passing for the subject.
- "Hi, My name is"&BrowseGallery1.Selected.Name&"From,"&BrowseGallery1.Selected.Place is passing for the body of the email.
Where “Hi, My name” and "From," are Static
BrowseGallery1.Selected.Name AND BrowseGallery1.Selected.Place are dynamic values
Let's save the app, publish and send the email on click
Result
You can even construct the email body in the flows with HTML formats. Here, I showed how to get a basic idea on how to interact with the flows with PowerApps.
Conclusion
This article showed us how to create flows, trigger them from PowerApps, and pass the dynamic values to flows.
Thank you.