web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : Z210oZqQWFayjhpbhxlBjp
Power Automate - Using Flows
Answered

Unable to loop/repeat "initialize Variable" to parse similar data from an email

Like (0) ShareShare
ReportReport
Posted on 27 Aug 2021 14:55:23 by 45

I am trying to parse the names of students from an email. But it is only giving me the first name. Tried to use the "apply to each" function but it's saying we can't use it along with the "initialize variable" function. Request your help here, please. 

 

This is the HTML version of the email. I've erased the unnecessary stuff for easier explanation. 

 

Ab3l_1-1630075511137.png

 

I want those names (Alex, Lisa, Martha) It is not certain, in some emails there could be more or less names. But the HTML first and last words are the same. See I have marked them in purple and green color. 

 

This is the flow. I have mentioned the formula as well:

 

Ab3l_2-1630075835881.png

 

It's working but giving only the first student's name. After getting the name, I have to put them on an excel table. And for that this is what I am doing:

Ab3l_3-1630075957489.png

The excel: 

 

Ab3l_4-1630075987241.png

 

 

 

Please lemme know, how to loop it?

I have the same question (0)
  • Ab3l Profile Picture
    45 on 29 Aug 2021 at 07:29:59
    Re: Unable to loop/repeat "initialize Variable" to parse similar data from an email

    Wow! This worked as charm! Thank you so much bro. 

  • eric-cheng Profile Picture
    5,171 on 28 Aug 2021 at 14:48:06
    Re: Unable to loop/repeat "initialize Variable" to parse similar data from an email

    Hi @Ab3l ,

     

    I am not in front of my computer but the easiest thing would be to add a condition where current item contains 'Student name:'

     

    Not elegant by any means but should solve your issue.

     

    --------------------------------------------------------------------------
    If I have answered your question, please mark my post as a solution
    If you have found my response helpful, please give it a thumbs up

    Connect on LinkedIn

  • Ab3l Profile Picture
    45 on 28 Aug 2021 at 13:30:46
    Re: Unable to loop/repeat "initialize Variable" to parse similar data from an email

    Thanks a lot for your time, brother. đꙂ

     

    It's working. But there is one small issue. We are splitting using a line break here inside the array but in the actual HTML email, it's a single line. 
    Like this: 

    Ab3l_0-1630157229280.png

     

    But that's not an issue, I split it using split(variables('Names'), 'Student name: ')

     

    Now the problem is that it's creating one extra line. Like when there are 3 student names, there are 4 "apply to each" output result. The first three are the names, and the last part is the broken HTML line. any way to get rid of that line while putting it on excel?

  • Verified answer
    eric-cheng Profile Picture
    5,171 on 27 Aug 2021 at 16:22:52
    Re: Unable to loop/repeat "initialize Variable" to parse similar data from an email

    Hi  @Ab3l ,

     

    See if this helps.

    Screenshot_20210828-021628_Chrome.jpg

    @split(variables('Names'),variables('Space'))
     

    You can then apply your first() and last() formula to extract individual names within the loop.

     

    Screenshot_20210828-021648_Chrome.jpg

    --------------------------------------------------------------------------
    If I have answered your question, please mark my post as a solution
    If you have found my response helpful, please give it a thumbs up

    Connect on LinkedIn

     

  • Ab3l Profile Picture
    45 on 27 Aug 2021 at 14:58:38
    Re: Unable to loop/repeat "initialize Variable" to parse similar data from an email

    Any help brothers @eric-cheng @v-bofeng-msft ? 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2

Featured topics

Restore a deleted flow
Loading complete