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