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 / Splitting Name Field(F...
Power Automate
Answered

Splitting Name Field(First Name ,Last Name) from an email body

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all,

I am working on a email body form scenario where I have to extract Name, Email and Company etc from an email body form to input my UI Flow. Problem is, when I am trying to extract and split Name field (First Name, Last Name), it shows the following result :

 

Here is my flow :

 

emailbody1.PNG

 

Extracting Name:

last(split(body('Convert_email_HTML_to_Text'),'Name:'))
 

emailbody2.PNG

 

First name:

split(outputs('Extracting_Name'),' ')[0]
 
emailbody3.PNG
 

Last Name:

split(outputs('Extracting_Name'),' ')[1]
 
emailbody4.PNG
 
Here in the last output when I am extracting the last name it also coming with the next line Which is Email.
Can anyone please help me on this?
 
Regards,
- Ahmad Khan
Categories:
  • efialttes Profile Picture
    14,756 on at

    Hi!

    THe problem is, there is not a space between 'Ahmad' and 'Email:' but a NewLine instead

    Did you consider this alternate approach?

    first(split(split(outputs('Extracting_Name'),' ')[1],'
    '))

    Just remember to hit enter

     

    IF problem is not solved this way, please let us know

    Hope this helps

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for your response.

     

  • efialttes Profile Picture
    14,756 on at

    Hi!

    JUst edited my first response with one suggestion

    THanx!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

     

    I

     
  • efialttes Profile Picture
    14,756 on at

    Hi again!

    Add a Compose action block and assign as its input this expression instead

    split(trim(uriComponentToString(replace(uriComponent(body('Html_to_text')),'%0A','~~'))),'~~')

    If this second approach works, its output will be an array, each element a line from your email.

     

    NExt you will need to add a 'Filter array' to extract the line with 'Name:' inside, assign as its input this expression from above, now configure its condition rule to verify if current item() contains 'Name: '

    Finally, you will need to get first result from 'Filter array' output and split it by using space delimiter

    HOpe this makes sense

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi 
    Thank you for you patience

    I am facing this error when I am trying to split my name into first and last name:

     

    emailbody7.PNG

     

    Regards,

    Ahmad

  • efialttes Profile Picture
    14,756 on at

    Hi!

    No problema, we are very close to a Happy Ending!

    Please note that Filter array output is also an Array, even though this one has a single element. So the error is reporting this problem

    I believe you need to change your current expression in 'First Name' compose action block, please try with this other instead:

    first(split(first(body('Filter_array')),' '))

     

    Now, 'Last Name' should be something similar

    last(split(first(body('Filter_array')),' '))

    Hope this helps

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I am still not getting the desire result:

     

    emailbody6.PNG 

     

    Regards,

    Ahmad

  • Verified answer
    efialttes Profile Picture
    14,756 on at

    OMG! I forgot about the 'Name:' !!!

    So in order to get Fist Name this expression hould do the magic:

    split(first(body('Filter_array')),' ')[1]

     

    Expression suggested for 'Last Name' is right?

     

    last(split(first(body('Filter_array')),' '))

    Hope this helps

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you   for your help. it works successfully.

     

    now when I am following further steps and input the same spilt function on Phone field from an email body it gives me this following result:

     

    Phone: 

    split(first(body('Filter_array')),' ')[1]

     

    emailbody8.PNG

     

    Regards,

    Ahmad

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 289

#2
11manish Profile Picture

11manish 282 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 119

Last 30 days Overall leaderboard