cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Socrates
Level: Powered On

Lookup email ID in a column in a Excel Table

Hello

 

I'd like some help on how finish off a Flow I've started, please. I'm currently getting a list of emails that are sent from a certain email address:

email.png

 

That all works fine, but I'd like to lookup the Message ID of these emails in an Excel Table (Stored in OneDrive - table contains columns titled: SentDate, EmailID, Subject, Body Preview, To). If the message ID is there, then nothing happens, but if the message ID isn't present in the excel sheet, to add the relevant information in.

 

I can't quite get it to work. I only seem to be able to add all the emails in again, or get caught in a loop where it's adding every email, for every row.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Lookup email ID in a column in a Excel Table

@Socrates 

Hi there!  So, it sounds like you're trying to sync your emails (in a sense) with a spreadsheet, right?  The reason (I'm guessing) you get all the emails added in again is because as a condition checks each of the emails against your list, it will add it in if it doesn't find a match, right?

For example, if I have 10 emails in my inbox (wishful thinking) and the first 9 are already in the spreadsheet, it will look at email #1 in my inbox and compare that to row one in my spreadsheet...not a match?  Add a row.  Row two...not a match? add a row.

 

And so on.

 

There are a couple of ways around this:

  • Change your trigger so that the Flow is triggered when a new email comes in, it adds it to the spreadsheet.  Then you won't have to check for duplicates.
  • Create a variable at the beginning, and then inside your Apply to Each loop (for matching against the Spreadsheet), update the variable with the email data, but only write it to the spreadsheet if you finish the loop without a match.

There are a few ways to get this done, but here's another thread of someone trying something similar.

 

Keep us posted.

-Ed-

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Lookup email ID in a column in a Excel Table

@Socrates 

Hi there!  So, it sounds like you're trying to sync your emails (in a sense) with a spreadsheet, right?  The reason (I'm guessing) you get all the emails added in again is because as a condition checks each of the emails against your list, it will add it in if it doesn't find a match, right?

For example, if I have 10 emails in my inbox (wishful thinking) and the first 9 are already in the spreadsheet, it will look at email #1 in my inbox and compare that to row one in my spreadsheet...not a match?  Add a row.  Row two...not a match? add a row.

 

And so on.

 

There are a couple of ways around this:

  • Change your trigger so that the Flow is triggered when a new email comes in, it adds it to the spreadsheet.  Then you won't have to check for duplicates.
  • Create a variable at the beginning, and then inside your Apply to Each loop (for matching against the Spreadsheet), update the variable with the email data, but only write it to the spreadsheet if you finish the loop without a match.

There are a few ways to get this done, but here's another thread of someone trying something similar.

 

Keep us posted.

-Ed-

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

View solution in original post

Socrates
Level: Powered On

Re: Lookup email ID in a column in a Excel Table

Thanks @edgonzales that link did help. Having the variable as the true/false was the biggest breakthrough for me.

For anyone that may stumble on this in the future, my flow ended up looking like this. The first 'apply to each' I had to use the values from the email rather than the lookup table.

screenshot.png

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (6,269)