Search code examples
sharepointpower-automatepower-platform

Power automate Get a certain part of the email body


today I'm working on a project where I get a piece of text from an email body and save it in a SharePoint list, but the piece of text varies every email from 1 to infinite, the pieces of text contain website domains or ip addresses.

This is the email we are receiving

In the picture shown above you can see that the "message" part contains 9 dots, these vary every email from 1 to infinite.

these dots contain websites or ip addresses.

Here is the flow I used for the email with 9 dots

Shown above is the flow i used for the email with 9 dots, but as i mentioned before these vary every time. in the flow im using right now im using an array to define the domainname rows, for example: site 1 = 49, site 2 = 51, site 3 = 53. The flow above works but I'm trying to find a easier way where power Automate automatically chooses/picks the domain names/ips, and used these in the rest of the flow.

What I'm trying to accomplish here is that power automate automatically sees how many dots there are and use these to make the array and post it to SharePoint (with the domain name behind the text aswell).

I have been searching on forums for a long time and couldn't find anything.

If any extra info is needed please tell me!

Thanks in advance,


Solution

  • You could convert the body to text, this will change the <li> tags to *. After that you can split that output on '* '. In a Select action you can use that array and per item you can look for the newline character to find the domain name value.

    Below is an example

    1.From Field in the Select action

    skip(split(outputs('Html_to_text')?['body'], '* '), 1)
    

    2.Map field (switched to Text mode)

    substring(item(), 0, indexOf(item(), decodeUriComponent('%0A')))
    

    enter image description here