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 :
Power Platform Community / Forums / Power Automate / Email body string extr...
Power Automate
Unanswered

Email body string extraction with two phrases using if statements

(0) ShareShare
ReportReport
Posted on by 257

Hi , 

this is a continuation of yesterday's post.

what I'm trying to do is basically extract the Time and Date for an email that comes with two varying key phrases.  

  • Proposed Start Time or Proposed Start Date
  • Proposed End Time or Proposed End Date

 

@Paulie78kindly helped with an awesome expression. So now, my flow works perfectly for both phrases (Proposed Start Time or Proposed Start Date) with this expression

  

 

if
(
 greater(indexOf( outputs('Html_to_text')?['body'], 'Proposed Start Time:'), 0),
 last(split(first(split(outputs('Html_to_text')?['body'],'MST')),'Proposed Start Time:')),
 if
 (
 greater(indexOf( outputs('Html_to_text')?['body'], 'Proposed Start Date:'), 0),
	 last(split(first(split(outputs('Html_to_text')?['body'],'MST')),'Proposed Start Date:')),
	'Not Found'
 )
)

 

 

 

however, for the Proposed End Time or Proposed End date, I can't get to work

 

I'm using the following expression 

 

 

if
(
 greater(indexOf( outputs('Html_to_text')?['body'], 'Proposed End Time:'), 0),
 last(split(first(split(outputs('Html_to_text')?['body'],'MST')),'Proposed End Time:')),
 if
 (
 greater(indexOf( outputs('Html_to_text')?['body'], 'Proposed End Date:'), 0),
	 last(split(first(split(outputs('Html_to_text')?['body'],'MST')),'Proposed End Date:')),
	'Not Found'
 )
)

 

 

When an email with Proposed End Time comes I get this

ProposedEndTime.jpg

 

then when an email with Proposed End Date I  get Not Found

ProposedEndDate.jpg

 

I know there's gotta be something incorrect with my expression, I just can't quite figure out what it is. 

 

Any help with be greatly appreciated

 

 

Categories:
I have the same question (0)
  • Verified answer
    Paulie78 Profile Picture
    8,422 Moderator on at
    Re: Email body string extraction with two phrases using if statements

    I didn't really look at your expression so can't tell you what is wrong with it, but try this:

     

    if
    (
     contains(outputs('Html_to_text')?['body'], 'Proposed Start Time:'),
     'Start Time Found',
     if
     (
     contains(outputs('Html_to_text')?['body'], 'Proposed Start Date:'),
    	'Start Date Found',
    	if
    	(
    	 contains(outputs('Html_to_text')?['body'], 'Proposed End Time:'),
     'Proposed End Time Found',
    	 if
     (
     contains(outputs('Html_to_text')?['body'], 'Proposed End Date:'),
    		'Proposed End Date Found',
    		'Nothing found! What a shame'
    	 )
    	)
     )
    )

     

    This version is a bit easier to comprehend.

    Put your substring expressions in where I have hard coded values such as "Start Time Found" etc. 

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 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard