cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KarlChristopher
Helper I
Helper I

Extracting a word before new line

Honestly, I am not sure if what I am doing is right, very new with MS Flow.

 

Anyway,

 

I have email regarding routers etc.

 

Usually the email consists of:

 

Affected CI: abcd.router.net

Assignment Group: abcdef

 

I would like to assign the abcd.router.net to a variable so I could check the SharePoint list if there is already an entry regarding that CI.

1 ACCEPTED SOLUTION

Accepted Solutions
v-yamao-msft
Community Support
Community Support

Hi @KarlChristopher,

 

Do you want to extract the Affected CI from the email body? Do all the emails always have the same format?

 

Please take the following flow for a reference.

 

The flow is triggered by When an email arrives with the following email body.

1.PNG

Add an action to convert email body to text.

 

Add a Compose action, use the following code:

length(body('Html_to_text'))

Add a Compose 2 action, use the following code:

add(indexOf(body('Html_to_text'),'Assignment Group'),6)

Add a Compose 3 action, use the following code:

substring(body('Html_to_text'),12,sub(outputs('Compose'),outputs('Compose_2')))

 

Then it will return the Affected CI as expected. Please check the following screenshots.

2.PNG3.PNG

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
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

3 REPLIES 3
v-yamao-msft
Community Support
Community Support

Hi @KarlChristopher,

 

Do you want to extract the Affected CI from the email body? Do all the emails always have the same format?

 

Please take the following flow for a reference.

 

The flow is triggered by When an email arrives with the following email body.

1.PNG

Add an action to convert email body to text.

 

Add a Compose action, use the following code:

length(body('Html_to_text'))

Add a Compose 2 action, use the following code:

add(indexOf(body('Html_to_text'),'Assignment Group'),6)

Add a Compose 3 action, use the following code:

substring(body('Html_to_text'),12,sub(outputs('Compose'),outputs('Compose_2')))

 

Then it will return the Affected CI as expected. Please check the following screenshots.

2.PNG3.PNG

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
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

Hello, thank you for the solution. However, I realized that the email I am extracting is actually encrypted or something when trying to do an HTML to text, hence I did very similar things than your solution but I only did it on one expression

That is a good solution, however I do not always know the contents of the next line. I  there a way to do it by finding the next neline character? "/n" will return an error because it is searching the entire document for newlines.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (2,266)