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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Extract specific text ...
Power Automate
Unanswered

Extract specific text from email subject

(0) ShareShare
ReportReport
Posted on by 137

Any help would be appreciated on this!  A quick overview of the Flow that I built: 

  1.  When a New Email Arrives (V3)
  2.  Condition
  3.  Export Email (V2)
  4.  Create File (SP Library)
  5.  Update File Properties
    1.  The SP library has a text field that I want to update with the employer name

Everything is working great except the last bit of metadata. 

 

The emails coming in always a subject that reads: "Report From Employer:" followed by a space.  And finally containing the employer name.  The employer name varies greatly in character size.  I need a proper function to successfully extract this bit (employer name) but my code is failing.  

 

(The employer name is also in the body of the text between a set of apostrophes if that is easier to work with.)

 

My current subject code:

 

substring(triggerBody()?['Subject'],add(lastIndexOf(triggerBody()?['Subject'],'Employer'),10),30)
 
report from employer.PNG
power automate.PNG
 
Thanks!
Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,707 Most Valuable Professional on at

    If the subject always reads the way you say it does then what you want is to get the substring starting just after the ':'.  So try this. Put the following in two Compose statements

    Split(trigerBody()?['Subject'], ':')
    trim(outputs('Compose')[1])

    That should give you the employer name  The only time this wouldn't work is when the Employer name has a ':' in it.  But that should probably be a rare occurrence. 

  • Scott0044 Profile Picture
    137 on at

    Thank you for the response.  I just learned that indeed there can be : within the employer name.  Any other recommendations?  

     

    Can I just grab the entire subject minus the first 22 characters?

  • Pstork1 Profile Picture
    68,707 Most Valuable Professional on at

    If there can be ':' within the subject name you will know because the array will have more than two items in it.  So its a little tougher, but just requires 1 additional step.  Loop through the array with an Apply to Each loop.  If its the first iteration, which you can check with the current iteration counter, do nothing.  Otherwise append all the rest of the entries to a string variable with a ':' after each.  That will rebuild the company name portion.

  • Verified answer
    v-alzhan-msft Profile Picture
    on at

    Hi @Scott0044 ,

     

    Please take a try with expression below:

    last(split(triggerBody()?['subject'],'Report From Employer:'))

     

    Best regards,

    Alice       

     

    Community Support Team _ Alice Zhang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Scott0044 Profile Picture
    137 on at

    Thank you!  The last bit of code provided by @v-alzhan-msft seems to be working during my tests!  Many thanks also to @Pstork1 

     

    Cheers!

  • Pstork1 Profile Picture
    68,707 Most Valuable Professional on at

    Please note: If the name of the business contains a ':' this will not give you the full name of the business.  It will only work if the only ':' in the subject line is the one in the prompt.  See the discussion below.  This is not a complete solution.

  • Scott0044 Profile Picture
    137 on at

    Hello @PS@v-alzhan-msft's code seems to be ok in my environment.  I ran a couple of successful tests which captured my requirements (see screen capture).  Apologies if I did not explain the requirement correctly in my initial request.  Is there something else that I'm missing?

     

    test.JPG

  • maries1986 Profile Picture
    162 on at

    Thank you for this solution!  i had been hunting for a solution all day!   works great 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard