Introduction
In business scenarios where you don't want to call a Power Automate Flow from Power Apps to send an email or push notifications, Microsoft has made our lives easier with connectors like Mail, Outlook.com, Office365Outlook, and so on. I am writing a series of articles where you will see how we can use these connectors to trigger emails directly to users' desired mailboxes or send a push notification to Power Apps using Power Apps Notifications/ Power Apps Notifications (V2) connectors. In this article, let's start with the Mail connector and understand the benefits and limitations along with a sample to simplify it further.
Mail Connector
It is important to understand that the Mail connector has 5 API calls per connection for 5 minutes and it can extend up to 100 API calls per connection for 24 hours. Hence, according to Microsoft documentation (see Reference section for the link to this documentation) Mail connector can be used to send
infrequent emails. So with that said, while designing the email configuration within your application it is very important to understand the frequency of emails to be sent in your business use case. Mail connectors are not suitable for bulk email functionalities however can be used for minimal usage only. Sometimes there are cases where your business does not want to authenticate Outlook connectors, and Mail connectors come in handy then. Additionally, Mail connectors send emails from Power Apps (using
[email protected]) and not as a specified person or the currently logged-in user who is triggering the email.
Item |
Description |
Action in Power Apps |
Send Email Notification (V3) |
Operation ID
|
SendEmailV3 |
Deprecated Operation ID | SendEmail |
Understand the Action Parameters: Send Email Notification (V3)
Name |
Key |
Required |
Type |
To |
to |
True |
string |
To Names |
toname |
False |
string
|
Subject |
subject |
True |
string
|
Body |
text |
True |
html |
Is Html |
ishtml |
True |
boolean |
CC |
cc |
False |
string
|
CC Names |
ccname |
False |
string
|
BCC |
bcc |
False |
string
|
BCC Names |
became |
False |
string
|
Attachment |
files |
False |
byte
|
Attachment File Name |
filenames |
False |
string
|
Syntax
- Mail.SendEmailV3(
- to,
- subject,
- text,
- ishtml,
- {
- toname:Text,
- cc:Text,
- ccname:Text,
- bcc:Text,
- bccname:Text,
- files:Blob,
- filename:Text
- }
- )
Sample: Send an email notification using Mail connector
To run through a sample, complete the below pre-requisites:
- Create a SharePoint list with Title, Description(Multiple lines of Text), isSendEmail(Yes/No, default- No) fields
- Create a Canvas app from blank
- Add SharePoint list created in 1 as a data source to the app
- Insert an Edit form and set its Default property to FormMode.New
- Insert a Button control and set its Text property to "Submit"
Refer to the below screenshots to validate the above points.
SharePoint List
Canvas App Form
Now the main part of this article comes to light. Go ahead and add Mail connector to the data source as stated below:
Step 2
Add the below code to OnSelect property of Submit button:
- SubmitForm(Form2);
- If(
- DataCardValue6.Value,
- Mail.SendEmailV3(
- "YourEmailAddres",
- "Testing Email",
- "Email Body goes here",
- true
- )
- );
- ResetForm(Form2);
where,
- DataCardValue6 is the isSendEmail boolean value on the form
- Your email address - To email. Paste your email address here For eg: [email protected]
- Testing Email - Subject of the email
- Email Body goes here - Body of the email (can be an HTML text too)
- true - ishtml by default always set to true
Step 3
Run the app and fill out the form details and click on Submit button. The app goes ahead and submits the form details to the SharePoint list and triggers an email.
Notice the from the email it says Microsoft Power Apps and Power Automate <
[email protected]>
Summary
We have seen an introduction to Mail connector and how it can be used in business applications, as well as the syntax format and a simple send an email on form submit.
References
- https://docs.microsoft.com/en-us/connectors/sendmail/