cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

When a new row is added send email to person

I am new to using Power Automate. I have a problem with creating a flow. I will briefly describe what I would like to do.

When a new row appear in an excel file, I would like it to automatically send an email with the file as an attachment to the person whose email address is given in this new row.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Karolina17 ,

 

About the duplicated call, my guess is that you are getting one for the new row insertion (which is expected), and another for Power Automate "Update a row" task, which is modifying the file to include the "TAK" into the "sent" column. Ideally, this second flow run should not result in a new email sending, as we won't have any empty values in "sent" column, but it is possible to happen, as this second flow run can happen in less than 5 minutes from the file update, not capturing its changes. 

 

A possible solution may be to change the "interval" property from your trigger, setting it to 5 minutes:

rzaneti_0-1709296176770.png

 

 

This property controls how often Power Automate will monitor the changes in the SharePoint folder. By setting it to a larger amount of minutes, you must prevent Power Automate to capture the old Excel file version.

 

About limiting the flow run to changes in only one sheet, I don't think that it may be possible, as the trigger is related to a SharePoint control, and not to Excel itself.

 

Let me know if the recommended change works for you!

View solution in original post

17 REPLIES 17
rzaneti
Super User
Super User

Hi @Karolina17 ,

 

I don't know exactly how is your Excel table organized, but you must need (1) a column with unique values (like an ID column) and (2) a column to identify if the email was already sent by the flow. Here is a quick step-by-step about how to implement the flow.

 

References

Before we start, I'm sharing some articles about the topics discussed in this solution. It can be useful for you or any users that find this thread in the future:

- Dynamic contents and expressions in Power Automate: http://digitalmill.net/2023/07/31/using-dynamic-content-in-power-automate/ 

- Looping arrays: http://digitalmill.net/2023/07/12/using-loops-and-accessing-array-elements-in-power-automate/ 

- Integrating Power Automate with Excel tables: http://digitalmill.net/2023/07/17/integrating-power-automate-and-excel-tables/ 

- Inserting and updating data in Excel tables with Power Automate: http://digitalmill.net/2023/07/24/inserting-and-updating-data-into-excel-tables-with-power-automate/ 

 

Overview

This is how my table looks like: there is an ID column, that is used to identify the records; an email column, that must be used by the flow to populate the "Send email" action; and a "sent" column, that identifies if the email related to this record was already sent or not:

rzaneti_1-1708375945157.png

 

The "sent" column must not be fille by the user: the flow will automatically populate it once it sends the email.

 

Step 1 - Configuring the trigger

Let's start by creating a flow with the "When an item or file is modified", from SharePoint connector (you can also use it from OneDrive connector, if your file is stored in OneDrive):

rzaneti_2-1708376070253.png

 

Fill in with the details about your file's location (SharePoint Site, Library and folder). You may notice that there is no option to select the individual file, but only a folder to be monitored. This is expected, and technically this trigger is capturing the modification event of any file located into the folder selected by you.

 

To ensure that the trigger will monitor only a specific file, you will need to add a trigger condition. In your trigger, select the "Settings" tab (highlighted in yellow) and add a trigger condition (highlighted in green):

rzaneti_3-1708376282769.png

 

The condition must be the following: @equals(triggerBody()?['{FilenameWithExtension}'], 'emails to send.xlsx'), where you must to replace the text in red for the name with extension of the Excel file where your table is stored.

 

Although the trigger is monitoring changes happening in any file allocated in the folder selected by you, the flow will be triggered only if a change is made in your Excel file

 

Step 2 - Capturing the new table records

Now it's time to add a "List rows present in a table" action. Populate it with the details of your flow and add a filter query to capture only the records where the column "sent" is empty: 

rzaneti_4-1708376458516.png

 

The filter query text is sent eq '', and you must replace the text in red for the name of the column that you are using to register that an email was sent to the record.

 

This control is important to ensure that you won't be sending emails to old records. By default, Power Automate will retrieve all records from the table, and it won't be able to identify the new records included during the recent file changes. Once you insert a column to perform this control, Power Automate will be able to filter out all of the records that already had an email sent in the past (by using the filter query from above), and retrieving only the new records added to the table. 

 

Step 3 - Sending the email

Power Automate returned only the new records added to the table, so you can loop them all with a "For each" or "Apply to each" and add your email action inside it. For this example, I'm using a "Compose" action just to display the email of the current loop iteration, but you can replace it for a "Send email" and populate the "To" input with the dynamic content of "email": 

rzaneti_5-1708376975072.png

 

Also, you must allocate an "Update a row" action inside the loop, to register in the table whenever the email is sent to the user. Just populate the action with the table details, set the "id" as "Key column" (highlighted in yellow), set the "id" dynamic content as "Key value" (highlighted in blue) and set the "sent" column as "Yes" (highlighted in green):

rzaneti_7-1708377208174.png

 

Testing the flow

The flow is complete. I've included a new row into the table for testing, without filling the "sent" column:

rzaneti_6-1708377165605.png

 

As expected, the flow ran and identified retrieved only one record from Excel (highlighted in yellow), which email is test1@test.com (highlighted in green):

rzaneti_8-1708377366200.png

 

And after that, the flow automatically updated the "sent" column to "Yes":

rzaneti_9-1708377434436.png

 

 

Let me know if it works for you or if you need any additional help!

 

-------------------------------------------------------------------------
If this is the answer for your question, please mark the post as Solved.
If this answer helps you in any way, please give it a like.

http://digitalmill.net/ 
https://www.linkedin.com/in/raphael-haus-zaneti/ 

Hi, thank you for your help. I have a problem with the fact that messages are sent several times, I added a condition but it doesn't work.

Karolina17_0-1708412138214.png

 

Hi @Karolina17 ,

 

What do you have as input for the condition?

I have this as input

Karolina17_1-1708432477167.png

 

Hi @Karolina17 ,

 

As you are using the condition to filter out the records where you already have a "TAK" in the "sent" column, make sure that the "TAK" in Excel is in upper case (Power Automate will be case sensitive for this comparison), and without any extra blanks at the beginning or end of the text.

 

Alternatively, you can use an expression to test if the "sent" column is empty and, if yes, send the email and run the update action. This works fine for any text added to "sent" column, ignoring the letters case and the extra blanks:

rzaneti_0-1708471031646.png

 

Expression: empty(items('For_each')?['sent']), and make sure to change the items('For_each')?['sent'reference to your actual "sent" column dynamic content.  

 

Note: by applying this change, make sure to move your "Send email" and "Update row" actions to the "True" block of the Condition.

 

@rzaneti I added this condition, but after 1 minute I sent the same message again with this flow.

Karolina17_0-1708494948296.pngKarolina17_1-1708495159110.png

 

rzaneti
Super User
Super User

Hi @Karolina17 ,

 

The Excel "List rows present in a table" requires some minutes to capture file updates, so when you update a record in an run the flow after one minute, it is possible that it is using data from the previous version (in your case, without any information in the "sent" column. 

 

Some questions:

- Are you facing the same issue when you wait 5 minutes between two flow runs?

- If yes, is your Excel table "sent" column updated after running the flow?

- If not, please, share an image of your Excel table

takolota
Multi Super User
Multi Super User

If you wanted an automated trigger, then there is also this When an Excel row is created, modified, or deleted template: https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/When-an-Excel-row-is-created-modified-or...

Hi @rzaneti,

-After 1 test, flow sent me 2 messages as if it had started 2 times.Karolina17_1-1709270847117.png

 

Karolina17_0-1709270224469.png

-After 5 minutes I entered another adres email into the file, the flow started 2 times but sent 1 message.

Karolina17_2-1709270874356.png

- Yes, my "sent" column updated after running the flow

Karolina17_3-1709271313410.png

- I have also another question. In this file now I will have 3 tables. I would like this flow to start when the change occurs in first "1" sheet. Is it possible to add?

Hi @Karolina17 ,

 

About the duplicated call, my guess is that you are getting one for the new row insertion (which is expected), and another for Power Automate "Update a row" task, which is modifying the file to include the "TAK" into the "sent" column. Ideally, this second flow run should not result in a new email sending, as we won't have any empty values in "sent" column, but it is possible to happen, as this second flow run can happen in less than 5 minutes from the file update, not capturing its changes. 

 

A possible solution may be to change the "interval" property from your trigger, setting it to 5 minutes:

rzaneti_0-1709296176770.png

 

 

This property controls how often Power Automate will monitor the changes in the SharePoint folder. By setting it to a larger amount of minutes, you must prevent Power Automate to capture the old Excel file version.

 

About limiting the flow run to changes in only one sheet, I don't think that it may be possible, as the trigger is related to a SharePoint control, and not to Excel itself.

 

Let me know if the recommended change works for you!

Hi @rzaneti 

 

I have made a similar flow as your instruction. The flow works. However I'm stuck with this.

 

The name Robert, it keeps sending mail repeatedly till I have to turn the flow off. In the column Status, it doesn't fill 'Sent' into my excel file as the action Update a row set.

 

In addition, why it doesn't display sheet name as in the excel file in the Table field, just 'Table3' [highlighted].

 

Could you please give me instruction to fix these problem?

Hi @KVIDP ,

 

It looks like Robert's candidate number is the same of Alex's, when it should be different. When running the "Update a row" action, Power Automate will search for the first match in the table, which is Alex, letting Robert's status as empty.

 

If your table is just an example, I recommend you to change the Alex candidate number and try to run it again. If the candidate number column is supposed to receive duplicated values, I recommend you to use a different column as key (maybe email address).

 

Let me know if it works for you or if you need any additional help!

 

-------------------------------------------------------------------------
If this is the answer for your question, please mark the post as Solved.
If this answer helps you in any way, please give it a like.

http://digitalmill.net/ 
https://www.linkedin.com/in/raphael-haus-zaneti/ 

KVIDP
New Member

Hi @rzaneti ,

 

I've change the candidate number. It worked but I still received email multiple times (one mail per a minute) before it stop. This time, 'Sent' was automatically fill in the column Status. It supposed to send only one email and mark 'Sent' to the table, no repeatedly sending mail. You have any advice for me?

Hi @KVIDP ,

 

Can you confirm the "Interval" used in the trigger? by default, it is set as 1 minute, but Excel files can take up to 5 minutes to be updated. It means that SharePoint captures a change in your Excel file (triggering the flow again), but Excel didn't register the change yet (set the column as "Sent"), resulting in these multiple email sending. 

 

I recommend you to set this value to 5 minutes, so SharePoint will wait a little while to look for changes in the file (and, once it does it, the "Sent" column will be already filled in Excel):

rzaneti_0-1715340622316.png

 

 

Let me know if it works!

KVIDP
New Member

Hi @rzaneti ,

Actually I've already set 5 minutes interval. Should I increase up to 10 minutes interval?

Hi @KVIDP ,

 

In this case, I recommend you to increase it to 7 or 10, if your requirements allow it. If the error persists, please share some images of your flow design. 

 

Let me know if it works for you or if you need any additional help!

 

-------------------------------------------------------------------------
If this is the answer for your question, please mark the post as Solved.
If this answer helps you in any way, please give it a like.

http://digitalmill.net/ 
https://www.linkedin.com/in/raphael-haus-zaneti/ 

KVIDP
New Member

Hi @rzaneti ,

 

I have tried setting the interval to 10 minutes and 15 minutes, but the error still persists, mail was sent least 3 times. I noticed that the 'Sent' status is filled in the Status column almost immediately. However, the email is still sent multiple times. In addition, I also noticed that after changing the interval to 10 minutes or 15 minutes and clicking Save, then running a test, after the test is finished, when I click Edit, the Interval is automatically adjusted back to 5 minutes. It's really confusing.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (715)