logo
search
Others

How to Extract Text from Email Body Correctly in Power Automate

Maira MehtabMaira Mehtab Sep 22, 2026 868 views

Question details

The user needs to extract specific text values, such as Snapshot and Environment details, from deployment emails using a Power Automate flow.

Product
Microsoft Power Automate
Device & OS
not provided
Scenario
Automating the extraction of specific data points from incoming deployment emails using Compose actions.
Observed behavior
Compose actions do not return the expected string values, and the indexOf function returns an error stating it received an object instead of a string.
Before you start

Ensure you have a sample email payload and can access the run history of your Power Automate flow to inspect the exact inputs and outputs of your Compose actions.

Solution 1Recommended

Troubleshoot Data Types and Expressions

Resolve the 'indexOf' object error by ensuring the email body content is correctly converted to a plain text string before extraction.

The error indicating that 'indexOf' received an object instead of a string usually occurs when the email body output is passed as a complex JSON object or HTML block. To fix this, you must ensure the dynamic content is strictly formatted as a string.

1
Convert HTML to Text

Add an 'Html to text' action in your flow immediately after receiving the email. Pass the email body into this action to strip out HTML tags and ensure the output is a plain string.

2
Format with String Function

In your Compose action, check your 'indexOf' expression. Wrap your dynamic content in a 'string()' function to force Power Automate to interpret it correctly (e.g., indexOf(string(outputs('Html_to_text')), 'Snapshot')).

3
Inspect Flow Run History

Run a test flow and click on the specific run in your Flow History. Review the raw inputs and outputs of the Compose action to confirm it is receiving raw text and not a JSON object.

4
Seek Specialized Assistance

If complex expressions continue to fail, gather your flow structure, sample payload, and expressions, and post them in the Microsoft Power Platform Community for advanced troubleshooting.

Community Support: Because Power Automate involves advanced logic and expressions, it falls outside standard Office troubleshooting. The Microsoft Power Platform Community is the best resource for flow-specific issues.
Free Microsoft Office alternative

Choose WPS Office for Seamless and Free Document Management

While Power Automate handles complex Microsoft ecosystem workflows, everyday office tasks require a lightweight, highly compatible suite. WPS Office is a powerful, free alternative to Microsoft Office, offering Writer, Spreadsheet, and Presentation tools in one application.

  1. 1. Download WPS Office: Visit the official WPS website and download the free installation package for your operating system.
  2. 2. Install the Software: Run the downloaded installer and follow the simple on-screen instructions to set up WPS Office on your device.
  3. 3. Open and Create: Launch WPS Office and instantly open your existing Microsoft Office files or create new documents seamlessly.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats.Built-in PDF editing, conversion, and signing capabilities.Lightweight installation with a tabbed, user-friendly interface.Free to use with built-in AI assistance to streamline your daily tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Power Automate's indexOf function return an object error?

This error happens when the dynamic content passed to the function is structured as an object (like a JSON array or complex email object) instead of plain text. You can use the string() function to convert the dynamic content before using indexOf.

How do I extract specific text from an email body in Power Automate?

Use the 'Html to text' action to convert the email body into a plain string. Then, use a combination of indexOf and substring functions inside a Compose action to locate and extract the required values based on text markers.

Where can I get advanced support for complex Power Automate flows?

Since Power Automate involves advanced logic and expressions that are beyond typical Microsoft 365 desktop support, the best place for specialized assistance is the Microsoft Power Platform Community forums.