web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Extracting text from e...
Power Automate
Answered

Extracting text from email

(0) ShareShare
ReportReport
Posted on by 10

Hi I have an email like this

Database name: Test
Size: 123123K
Total: 871293

Database name: Test2
Size: 1231245K
Total: 9081923

How should I extract both database name separately using power automate?

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @Orwen23 

    Will there always be two Database Names in the email or can the number vary?

     

  • Orwen23 Profile Picture
    10 on at

    Hi @ScottShearer , The 'Database name' in the email can be vary based on the output of my email. 

    in this example I just used two. However, I also want the two 'Database name' value to be stored in a separate variables because I need to paste the two extracted values in an excel file. I appreciate your response.

  • sandeepstw Profile Picture
    312 Moderator on at

    Hi There,

     

    To extract multiple pieces of information from an email body, you can use the "Parse JSON" action in Power Automate. But first, you'll need to transform the email content into a JSON format.

    Here's a step-by-step guide:

    1. After your trigger action (for example, "When a new email arrives" in Office 365 Outlook), add a "Compose" action. In the "Inputs" field, use the replace function to format the email body as JSON. If the email body is in the variable `emailBody`, the expression would look like this: `replace(replace(replace(replace(emailBody, 'Database name:', '\"Database name\":'), 'Size:', ',\"Size\":'), 'Total:', ',\"Total\":'), '\n\n', '},{')`. This will replace the property names and newline characters in the email body with appropriate JSON syntax.

    2. Add a second "Compose" action. In the "Inputs" field, use the concat function to add brackets to the beginning and end of the JSON string. The expression would look like this: `concat('[{', outputs('Compose'), '}]')`. This will make the JSON string an array of objects.

    3. Add a "Parse JSON" action. In the "Content" field, enter the output of the second "Compose" action. In the "Schema" field, enter the following JSON schema:

    ```json
    {
    "type": "array",
    "items": {
    "type": "object",
    "properties": {
    "Database name": {
    "type": "string"
    },
    "Size": {
    "type": "string"
    },
    "Total": {
    "type": "string"
    }
    },
    "required": [
    "Database name",
    "Size",
    "Total"
    ]
    }
    }
    ```

    Now, the output of the "Parse JSON" action will be an array of objects. Each object will represent a database with properties for "Database name", "Size", and "Total". You can access this data in subsequent actions by using the "Parse JSON" action output. For example, to get the name of the first database, you would use the expression `body('Parse_JSON')[0]['Database name']`.

     

    Please give kudos and mark as solution if it works. 

     

    Thanks,

    Sandeep Mishra

     

  • Orwen23 Profile Picture
    10 on at

    Hi @AlexEncodian , I already performed the method 1 but my problem is it will only get the first 'Database Name' on my email.

  • AlexEncodian Profile Picture
    4,409 Moderator on at

    @Orwen23 

    Then you havent split it like I described. First you split, then you extract each split string (there will only be one Database name per split string)

  • Verified answer
    Chriddle Profile Picture
    8,686 Super User 2026 Season 1 on at

    This only works if your text is formatted exactly as you specified:

    Chriddle_0-1689061575894.png

    DbNames is a select action

    From:

    split(
    	outputs('Txt'),
    	decodeUriComponent('%0A%0A')
    )

    Splitting the text at double line breaks (for Windows formatted line breaks crlf, this would be '%0D%0A%0D%0A')

     

    Map:

    split(
    	split(
    		item(),
    		decodeUriComponent('%0A')
    	)[0],
    	': '
    )[1]

    Splitting at single line break and taking the first row (inner split).

    Then splitting at colon+space and taking the second part (outer split)

     

    Result (body('DbNames')):

    [
     "Test",
     "Test2"
    ]

     

  • Orwen23 Profile Picture
    10 on at

    Thanks for your help guys! Problem solved. 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 785

#2
Valantis Profile Picture

Valantis 669

#3
Haque Profile Picture

Haque 563

Last 30 days Overall leaderboard