cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
neilhza
Regular Visitor

Extract text from first line of email up to a point

Hi,

 

Power Automate newbie here..

 

I am trying to extract a name from an email, which is simply contained in the first part of an email as plain text. The email looks something like this:

 

John Doe at ABC Inc has logged a ticket.

 

I am looking for the expression to use in the compose line to just extract the John Doe piece and store it as a variable called name. I saw this post: https://powerusers.microsoft.com/t5/Building-Flows/Extract-first-line-of-email-body/td-p/545440 which helps a little, but I'm not sure how to trim it at the "at" point. @v-litu-msft not sure if you can assist?

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @neilhza,

Add a compose to get the index of the 'at' staring position on your text.

vqiaqimsft_0-1653370003127.png

sub(int(indexOf(outputs('Html_to_text')?['body'],'at')),1)

indexof() gets you where the 'at' word starts, use the sub() function to get the last position of the needed string.

substring(outputs('Html_to_text')?['body'],0,outputs('Compose_2'))

vqiaqimsft_1-1653370209035.png

 

Best Regards,
Qi

View solution in original post

3 REPLIES 3
v-qiaqi-msft
Community Support
Community Support

Hi @neilhza,

If you want to extract text string from the email body, please check as below.

To extract only the John Doe from the body, I think you could use the substring() function to extract the first 8 characters:

substring(outputs('Html_to_text')?['body'],0,8)

vqiaqimsft_0-1653361003847.png

vqiaqimsft_1-1653361146831.jpeg

 

 

Best Regards,
Qi

That’s great, but how would I use the word “at” as the delimiter? As the name won’t always be 8 characters…

Hi @neilhza,

Add a compose to get the index of the 'at' staring position on your text.

vqiaqimsft_0-1653370003127.png

sub(int(indexOf(outputs('Html_to_text')?['body'],'at')),1)

indexof() gets you where the 'at' word starts, use the sub() function to get the last position of the needed string.

substring(outputs('Html_to_text')?['body'],0,outputs('Compose_2'))

vqiaqimsft_1-1653370209035.png

 

Best Regards,
Qi

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,461)