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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Extracting name from e...
Power Automate
Answered

Extracting name from email subject line

(1) ShareShare
ReportReport
Posted on by 326

Hi there, 

 

I am trying to extract a name from an email subject line. I have got as far as splitting something... but took off the first letter rather than the whole word. Please help!

 

The subject line is as follows:

Word Word Word Word FIRSTNAME LASTNAME number

 

I need the first name and last name (i.e. the 5th and 6th words put together). What's the best way to use an expression to get this?

 

Additionally, further down my flow I need to make sure that a flow doesn't trigger a second time if there are replies to an email (so RE or FW at the start). Is there a way to add a trigger condition or do something else so that this doesn't happen? Otherwise I am going to have duplicate rows.

 

Thank you 🙂

Categories:
I have the same question (0)
  • Verified answer
    trice602 Profile Picture
    16,034 Super User 2026 Season 1 on at

    Hi @cb23 ,

     

    Here's the expression to dynamically get your first and last.  Please mark as a solution and we can look at your second question.

     

    trice602_1-1695052673823.png

     

     

    slice(variables('Subject'), add(nthIndexOf(variables('Subject'), ' ', 4), 1), nthIndexOf(variables('Subject'), ' ', 6))

     

    trice602_0-1695052625967.png

     

     

  • rzaneti Profile Picture
    4,483 Super User 2026 Season 1 on at

    Hi @cb23 ,

     

    Assuming that the first and last names will always be the 5th and 6th words into the Subject Line, you can use this flow design:

    rzaneti_1-1695052517797.png

     

    Note: the variable 'text' is simulating your subject line. When applying this approach in your end, you don't need to create this first variable.

     

    Expressions used

    Variable 'array' expression: skip(split(variables('text')' '), 4) - make sure to replace the text in red for the dynamic content of your subject line.

     

    Variable 'name' expressions: variables('array')[0] and variables('array')[1] - make sure to replace the variables('array' for the dynamic content of your 'array' variable, generated from the subject line.

     

    Quick explanation about what is happening

    We are first transforming your subject line into an array, by using the split expression. As we are using a blank space as separator, each word will be an array element. As we know that we will be using only the 5th and the 6th element, we are applying a skip method, to ignore the first 4 elements from the generated array. So the final output from 'array' variable will be the following:
    rzaneti_2-1695052802550.png

     

    In 'name' variable, we are accessing the first and the second elements from the array. We use [0] to access its first element, and [1] to access its second one. It happens because the arrays in Power Automate are 'zero-indexed', so the count starts in zero, and not in 1.
     
    If this first approach works for you, we can move forward and work into the filter for the RE/FW!
     
    Also, I recommend you these 2 articles that I recently wrote about text mining in Power Automate and working with arrays in Power Automate:
     

    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/ 

     

     

     

     

     

     

     

  • cb23 Profile Picture
    326 on at

    Thanks so much Tom. That has worked!

  • cb23 Profile Picture
    326 on at

    Hello @rzaneti , thank you so much for your detailed reply. The explanation is much appreciated. I tried @trice602's expression and this worked even though it is slightly different to what you recommended. Are there any differences in the approach that I should know about that are potential pros or cons? Thanks again.

     

    I will check the RE/FW docs you shared tomorrow (I'm now finished work for the day!) 🙂 

  • cb23 Profile Picture
    326 on at

    Hi @trice602, just to follow this up - do you have any advice on the RE/FW element I mentioned? Thanks.

  • Verified answer
    trice602 Profile Picture
    16,034 Super User 2026 Season 1 on at

    Hi @cb23 ,

     

    I just tested this in a sample flow and it does identify the replies and forwards.  Please mark this reply as a solution too!  

     

    trice602_0-1695424172329.png

     

  • cb23 Profile Picture
    326 on at

    Perfect! Thanks so much @trice602 cb23_1-1695633056284.png

     

  • trice602 Profile Picture
    16,034 Super User 2026 Season 1 on at

    Nice!  Have a great week! 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 557

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 264 Super User 2026 Season 1

Last 30 days Overall leaderboard