cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

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
Highlighted
Community Support
Community Support

Re: Extract text from Body of an email in Flow

Hi @Anonymous,

 

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

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Extract text from Body of an email in Flow

Hi @Anonymous,

 

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

Highlighted
Advocate I
Advocate I

Re: Extract text from Body of an email in Flow

Thanks for posting a great solution to this!  I have a very similar requirement.  Using your substring code, I was able to extract most of what I want.  I don't know how to account for the varying length of the employer names.  

 

The email subject looks like this: "Report From Employer: Pittsburgh SharePoint Pro"  I'm looking to extract everything after the ":" and the space immediately following the colon (I counted 10 so looks good there with the first number).  The client has several daily reports and the employer name can range in character length.  Any recommendations?

 

substring(triggerBody()?['Subject'],add(lastIndexOf(triggerBody()?['Subject'],'Employer'),10),xx)

 

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Top Kudoed Authors
Users online (8,064)