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

Extract different parts of an Email Body

Hi there

 

Sorry, if it already has been here.

 

I want to extract different parts of a standard emailbody.

 

It normally looks like this:

 

Hello,

You have a new Document

 

XYZ-123456 000 01 Document 5 Manual

 

Please do not reply

 

I want to extract the following:

 

Type: XY

Number: 12345678

Number2: 000

Version: 01

Title: Document 5 Manual

 

Only the title can have different names. The Type has always 3 characters, the number is always 8 characters long, the number2 is always 3 characters long, the version is always 2 characters long.

 

After extraction i want to paste them into the corresponding cell in a sharepoint list.

 

Can someone help me here?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Mira_Ghaly
Dual Super User II
Dual Super User II

@PGRAF 

First of all you need to start your flow based on when an Email Arrives and then I believe you are receiving these emails with a specific subject, so you can have a subject filter like below, so you are only processing these emails:

Mira_Ghaly_0-1639606650973.png

The next step is to convert the Email from HTML to Text and then Parse the Text by using Split operations but you need to be specific on the number of new lines between each one , so I can provide a full example to you but if you gave me exactly how the email will be formatted with new lines.

Mira_Ghaly_1-1639606945745.png

Expression:

split(outputs('Html_to_text')?['body'],variables('newline'))

The output of this will be as below, an array of Strings so to pick the line you need to parse you need to pick the 6th element of the array which you can get with the below expression:

split(outputs('Html_to_text')?['body'],variables('newline'))[6]
[
  "Hello,",
  "",
  "You have a new Document",
  "",
  " ",
  "",
  "XYZ-123456 000 01 Document 5 Manual",
  "",
  " ",
  "",
  "Please do not reply",
  "",
  " "
]
 
Then you need to do further split by ' ' and then get first element of the array and split by '-' and so on.
 
If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here

View solution in original post

3 REPLIES 3
Mira_Ghaly
Dual Super User II
Dual Super User II

@PGRAF 

First of all you need to start your flow based on when an Email Arrives and then I believe you are receiving these emails with a specific subject, so you can have a subject filter like below, so you are only processing these emails:

Mira_Ghaly_0-1639606650973.png

The next step is to convert the Email from HTML to Text and then Parse the Text by using Split operations but you need to be specific on the number of new lines between each one , so I can provide a full example to you but if you gave me exactly how the email will be formatted with new lines.

Mira_Ghaly_1-1639606945745.png

Expression:

split(outputs('Html_to_text')?['body'],variables('newline'))

The output of this will be as below, an array of Strings so to pick the line you need to parse you need to pick the 6th element of the array which you can get with the below expression:

split(outputs('Html_to_text')?['body'],variables('newline'))[6]
[
  "Hello,",
  "",
  "You have a new Document",
  "",
  " ",
  "",
  "XYZ-123456 000 01 Document 5 Manual",
  "",
  " ",
  "",
  "Please do not reply",
  "",
  " "
]
 
Then you need to do further split by ' ' and then get first element of the array and split by '-' and so on.
 
If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
PGRAF
Regular Visitor

Hey thank you very much. It really worked. 

darkhorse12
Helper I
Helper I

Hello,

 

I am New to Power Automate,

 

Can you please help me with,

 

Hello Xyz,

Your Receipt # 121232 is your order .
 
Task: When i receive mail, it should create file in one drive, with name #121232(it has multiple numbers), But we have to save file like this only,
 
can you please helm me.
 
Thank you

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,915)