cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
LucianoBarragan
Level: Power Up

Extract text from Body of an email in Flow

I receive emails where Subject is like this:

 

Shopping cart created by Perla Hernandez requires your review and action – shopping cart # 0025371821

 

I want to extract the shopping cart number (always last 10 digist of the Subject) and insert in a Sharepoint list. How can I get this done?. 

 

Thanks for any help!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Extract text from Body of an email in Flow

Hi @LucianoBarragan,

 

Before offering workaround, here are some considerations for the subject string.

1. Will the shopping cart number always after the string "shopping cart #"?

2. Do the string "shopping cart # 0025371821" contains space character?

Assuming the Subject string is always in the format you posted, which is:

1. Number is always after the #,

2. There are spaces within "shopping cart # 0025371821"

Then we could do the following Expression to get the number:

Method 1:

Use the Last() and the Split () function:

 

last(split(triggerBody()?['Subject'],'#'))

Method 2:

 

Use the substring () and LastIndexof() function:

substring(triggerBody()?['Subject'],add(lastIndexOf(triggerBody()?['Subject'],'cart'),7),10)

Tested with your example Subject:

56.PNG57.PNG

 

Reference:

Use expressions in Flow actions

 

Regards,

Michael

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

View solution in original post

1 REPLY 1
Community Support Team
Community Support Team

Re: Extract text from Body of an email in Flow

Hi @LucianoBarragan,

 

Before offering workaround, here are some considerations for the subject string.

1. Will the shopping cart number always after the string "shopping cart #"?

2. Do the string "shopping cart # 0025371821" contains space character?

Assuming the Subject string is always in the format you posted, which is:

1. Number is always after the #,

2. There are spaces within "shopping cart # 0025371821"

Then we could do the following Expression to get the number:

Method 1:

Use the Last() and the Split () function:

 

last(split(triggerBody()?['Subject'],'#'))

Method 2:

 

Use the substring () and LastIndexof() function:

substring(triggerBody()?['Subject'],add(lastIndexOf(triggerBody()?['Subject'],'cart'),7),10)

Tested with your example Subject:

56.PNG57.PNG

 

Reference:

Use expressions in Flow actions

 

Regards,

Michael

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

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,070)