Skip to content
Home » Power Apps send email

Power Apps send email

Power Apps is a robust platform that allows you to create custom business applications with ease and efficiency. One of the most common and useful functionalities within Power Apps is the ability to send emails.




This can be useful for a variety of tasks, whether you need to notify users of important updates, automate workflows, or communicate with teams, sending emails from Power Apps can streamline your processes and enhance communication.

Let’s explore the step-by-step process of sending emails from Power Apps.

To send an email from Power Apps, we will be using Office365.SendEmailV2 function to send an email. Using this function, you can send an email to multiple users at once.

This function requires several parameters, including the recipient’s email ids, subject, and body.

Office365Outlook.SendEmailV2(
    "recipient email Id1;recipient email Id2",
    "Email Subject",
    "Email Body"
)

As you can see, here we have a gallery contains employee's details.

This gallery is connected to SharePoint list named EmpInfo as shown below.

To send an email from Power Apps, we need to add the Office 365 Outlook connector to the canvas app.

Sending an email using Office 365 outlook

Go to the Data pane, click on Add data and search for Outlook and select Office 365 Outlook data source.

Make sure, you add an email icon control inside gallery control.

Now, set the OnSelect property of the email icon control to the following formula.

Office365Outlook.SendEmailV2(
ThisItem.Email,
"Test email",
"Power Apps send an email testing"
)

Let’s understand the above formula.

First argument, is recipients email ids. ThisItem.Email, will select the current employee’s email id in gallery control.

Second argument, is the subject line and third argument is the email body.

Note that, for testing purpose we have provided the hard coded text for email subject and body. We can also use dynamic values, such as the values from other controls on the gallery or can get values from text input controls as well.

Now, test the email by running the app and click on email icon.

You can see, email is sent to the selected recipient.

Let’s open the email.

Sending email with HTML content in email body

To send HTML content, you need to specify the email body as HTML as shown in below formula.

Office365Outlook.SendEmailV2(
ThisItem.Email,
"Test email",
"<h2>Hello," & ThisItem.Name &
" </h2><p>This is Power Apps testing email.</p>" 
)

Now, run the app and you can see HTML content in email body.

 

Adding BCCs and CCs recipients in emails

The Office 365 Outlook connector also allows you to send emails with CCs and BCCs. You can add multiple CC and BCC users email.

To do this, you need to pass a record to the Office365.SendEmailV2 function with the Cc and Bcc fields populated.




For example, the following syntax shows how to send an email with one CC and one BCC recipient:

Office365Outlook.SendEmailV2( 
"recipient email ids", 
"Email Subject", "Email Body", 
{ Bcc:"BCCs recipients email ids", 
Cc:"CCs recipients email ids" }
 )

Let’s add BCCs and CCs email ids in above formula.

Now, run the app and click on send email icon. You can see, email is sent to recipient including BCC and CC recipient as well.

Setting the importance of an email message

You can also specify the importance of email messages such as High, Normal, or Low as shown in the below formula.

In this formula, we have set the importance of an email message as High.

Office365Outlook.SendEmailV2(
ThisItem.Email,
"Test email",
"Power Apps send an email testing",
{
Bcc: "BCCs recipients email ids",
CC:"CCs recipients email ids" ,
Importance: "High"
}
)

Let’s run the app, and you can see the importance of this email is marked as High.

Setting reply to email

In case, if you want recipient to reply on different email id then you can set ReplyTo email as shown below.

It is useful in a scenario when you don’t want the recipient to reply to you, then you can set the ReplyTo to email id such as noreply@xyz.com.

Or in case, if you want recipient to reply to you on different email id then you can provide that email id.

Office365Outlook.SendEmailV2(
ThisItem.Email,
"Test email",
"Power Apps send an email testing",
{
Bcc:"BCCs recipients email ids",
Cc: "CCs recipients email ids",
Importance: "High",
ReplyTo: "noreply@xyz.com"
}
)

Now, when you run the app. You can see, when you reply on email it will show To email id as noreply@xyz.com.

Sending email to all recipients listed in gallery

If you want to send email to all recipients then you can use Concat function to concatenates all of the recipients’ email addresses into one single text string, each one separated by a semicolon (;). In our case, we want to send email to all recipients listed in gallery.

Let’s, add one button control named it as Send email to all and set the OnSelect property of this button to below formula.

Office365Outlook.SendEmailV2(
Concat(
gal_emp.AllItems,
Email,
";"
),
"Test email",
"Sending email to all recipients"
)

In, case if you want to send email to selected recipients listed in gallery then you can filter the data.

Below formula, will send an email to all recipients belongs to country India.

Office365Outlook.SendEmailV2(
Concat(
Filter(
gal_emp.AllItems,
Country = "India"
),
Email,
";"
),
"Test email",
"Sending email to all recipients"
)

Adding an attachment in email

You can also send an attachment over email. To send an attachment using the Office365Outlook.SendEmailV2 function, you need to pass a table of attachments to the function. The structure of this table must include the column names Name and ContentBytes.




 Name column specifies the file name of the attachment and ContentBytes represent the actual data or content of the attachment in a binary format.

Let’s, send a image as an attachment over email. For this we will add image control.

Go to Insert tab and add a Add picture control.

Now, you can see Image control is added to screen.

Now, go to email icon and modify the formula to send an attachments over an email.

Office365Outlook.SendEmailV2(
ThisItem.Email,
"Test email",
"Power Apps send an email testing",
{
Attachments:Table(
{
Name: "PowerAppsLogo.jpg", 
ContentBytes: UploadedImage1.Image
}
)
}
)

Run the app now. After that, select an attachment from the image uploader. Then click on email icon to send email.

As you can see, recipients receive an attachment over email.

Sending email using email screen template

The Power Apps email template screen is a pre-built screen that you can add to your app to allow users to send emails. This email screen that lets users send an email from their Office 365 Outlook account.

You can customize the email template screen to meet your specific needs. For example, you can add additional controls to the screen, such as a control to select a template, a control to attach files, or a control to add CCs and BCCs.

It allows users to search for recipients in their orgs and add external email addresses, too. Lets, go to the New screen then select Email template.

Once, you add email screen template, you can see the screen looks like as shown below.

Let’s run the app to send an email to recipients. Now, search for users in your org, you can simply start typing their name in the text input box below To.




If you want to send an email to recipients outside your org, you can type out the full, valid email ids, and select the + icon that appears to the right of it.

After that, provide subject line and email body then click on send email button to send email.

 

Also Read..

Collection in Power Apps

ClearCollect function in Power Apps

Email validation in Power Apps

Highlight selected item in gallery

Gallery control : Design a gallery in Power Apps

Add Alternate background color to rows

Sort Items in gallery Power Apps

Loading

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.