Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

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

(0) ShareShare
ReportReport
Posted on 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?

  • Ab3l Profile Picture
    45 on at
    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 at
    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 at
    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 at
    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 at
    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow