cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Extract first line of email body

Hi community,

I am a beginner with Index strings and need help to extract words in the first line of an email. 

Reading through existing threads, I can see a few examples of text extraction using various Compose actions. However, they all seem to pick up text after a certain marker, or text that contains specific words/characters. In my case, that is an issue because there wouldn't be any standard wording in the email body. The only constant is the location of that text: always the first line, unless text is absent.

 

Context: Users are forwarding an email message containing an invoice to a dedicated inbox. This triggers a flow to automate a tracking process. If the user adds text before sending the message, I want to extract that text, which I'll refer to as "Description". An example of description could be: Client 1.

 

The output would be used for 2 purposes:

  1. "Client 1" added in the Description column of an Excel table.
  2. "Client 1" added in the file name of any attachments

A few considerations:

  • Some emails will not have a description. A user could just forward the email without adding any notes. In that case, the body of the email triggering the flow would start with either a divider line, or some variable form of ---Forwarded Email---- mention.
  • Need to avoid picking up text from the original email (the one that is forwarded). In the above example, we would only extract "Client 1".
  • I assume I would need to stop extracting after approximately 30 characters, because of file name character limits in OneDrive.

 

Would love if someone could confirm if that is achievable in Power Automate and to walk me through the various steps. Thanks in advance.

Clarifying that my flow works fine to create files from each attachment, as well as to create rows in the Excel table using standard dynamic content. The part that I need help solving is how to pull that Description from the email body (first line of text).

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Extract first line of email body

Hi @mgauvin,

 

If you want to get the first line of the Email body, you could refer to the following steps to do it:

split(outputs('Compose'),variables('Line'))[0]

Annotation 2020-05-01 145917.png

 

If it is a forward Email and it doesn't contain any description in the body. There is no ---Forwarded Email---- mentioned in the beginning of Email body, but there will be start with "Form:", so you could use startswith() function to determine whether to extract first line of Email.

 

If you want to get the first 30 characters, you could use the substring() function to do it:

substring('firstLineofEmailBody',0,30) 

But if the first line has no 30 characters the expression will report an error, so you should use length() function to determine it whether is longer than 30 characters firstly.

 

Best Regards,
Community Support Team _ Lin Tu
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 first line of email body

Hi @mgauvin,

 

If you want to get the first line of the Email body, you could refer to the following steps to do it:

split(outputs('Compose'),variables('Line'))[0]

Annotation 2020-05-01 145917.png

 

If it is a forward Email and it doesn't contain any description in the body. There is no ---Forwarded Email---- mentioned in the beginning of Email body, but there will be start with "Form:", so you could use startswith() function to determine whether to extract first line of Email.

 

If you want to get the first 30 characters, you could use the substring() function to do it:

substring('firstLineofEmailBody',0,30) 

But if the first line has no 30 characters the expression will report an error, so you should use length() function to determine it whether is longer than 30 characters firstly.

 

Best Regards,
Community Support Team _ Lin Tu
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
Helper V
Helper V

Re: Extract first line of email body

Hello @v-litu-msft ,

 

This is exactly what I am looking for,

 

I would like to take the first line from an email and update a SharePoint list with that information,

I'm new to expression, are you able to show me some screen shots on how to configure the flow to be able to get the first line from an email?

email.JPG

Thank you 

Claire

Helpful resources

Announcements
Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Top Solution Authors
Top Kudoed Authors
Users online (7,782)