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 / Help with extracting i...
Power Automate
Suggested Answer

Help with extracting information from body of email

(0) ShareShare
ReportReport
Posted on by 41
Hi all, I'm having some trouble with a flow and hoping to get some input. 
What I want to achieve is fairly simple. When a certain email arrives, it saves the whole email into a specific SharePoint folder. But what I want to do, is with the naming of the file, I want to extract some information from the body of the email and save this in the file name. It just doesn't seem to be working. So far my flow looks like this: 
 
1. When a new email arrives - recipient in there as well as a filter by the word 'Confirmation' in the subject line
2. Condition action - filter the work Confirmation in the subject - if yes, goes to step 3
3. This is where I run into trouble because I tried just saving the file, but in order to name the file correctly I have to extract the data I need from the email body. I've followed some instructions and used a HTML to text action which does what it says, but when I do a compose action after this to get the information it's failing. 
4. So this step is 'Compose' to extract the first peice of information which is the booking reference number. The second compose is the 'Title' thats in the body. 
 
I'm getting the following error: 
Unable to process template language expressions in action 'Compose_-_reference' inputs at line '0' and column '0': 'The template language function 'indexOf' expects two parameters: the string as the first parameter, the value to find the index of as the second parameter. The function was invoked with '3' parameter(s). Please see https://aka.ms/logicexpressions#indexof for usage details.'.
 
Below is the outputs from the HTML to text action: (i've replaced some confidential information with ***'s 
{
    "statusCode": 200,
    "headers": {
        "Cache-Control": "no-store, no-cache",
        "Pragma": "no-cache",
        "Transfer-Encoding": "chunked",
        "Vary": "Accept-Encoding",
        "Set-Cookie": "ARRAffinity=c85838fcf7ee5278cd880b7886ac6709900e8967f551e575ce4342d3d993c719;Path=/;HttpOnly;Secure;Domain=conversionservice-eus.******-eus-002.p.azurewebsites.net,ARRAffinitySameSite=c85838fcf7ee5278cd880b7886ac6709900e8967f551e575ce4342d3d993c719;Path=/;HttpOnly;SameSite=None;Secure;Domain=conversionservice-eus.******-eus-002.p.azurewebsites.net",
        "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
        "x-ms-request-id": "49621741-bc4c-46a5-a682-6764917e759d",
        "X-Content-Type-Options": "nosniff",
        "X-Frame-Options": "DENY",
        "x-ms-environment-id": "default-568a5434-7d3f-4714-b824-fe722e2748c0",
        "x-ms-tenant-id": "568a5434-7d3f-4714-b824-fe722e2748c0",
        "x-ms-dlp-re": "-|-|-",
        "x-ms-dlp-gu": "-|-",
        "Timing-Allow-Origin": "*",
        "x-ms-apihub-cached-response": "false",
        "x-ms-apihub-obo": "false",
        "Date": "Wed, 27 Nov 2024 15:57:11 GMT",
        "Content-Type": "text/html; charset=utf-8",
        "Content-Length": "2336",
        "Expires": "-1"
    },
    "body": "********* Meeting Room Booking System (Do Not Reply)\n\nBooking Details\n\n \n\nBooking Reference:\n\n1137009 [https://mqb.*******-app.com.**/dwsapps-v2/ghw?meetingKey=1137009]\n\nTitle:\n\n********* | *** meeting\n\nStatus:\n\nBooked\n\nRoom:\n\n***\n\nDate:\n\n15/01/2025\n\nTime:\n\n11:00-12:00\n\nBooked for:\n\n******, ******\n\nBooked by:\n\n******, Stephanie\n\nType:\n\nExternal-Room Only\n\nAttendees:\n\n5\n\nLayout:\n\n*Standard*\n\nState:\n\nConfirmed-External\n\nCost Code:\n\n****************\n\nSite:\n\nLONDON - ** ********** Street\n\n \n\nService Item\n\nTime\n\nQuantity\n\nCost\n\nNotes\n\nApproval Status\n\nWater Complimentary\n\n11:00\n\n5\n\n0.00\n\nPre-approved\n\n 
}
 
Basically, I need to extract the booking reference number 1137009 and the meeting title (in stars). If I can extract them as separate bits of data, I can then use them as part of the title for my saved file. Whats the best way to tackle this? I've used Chat GPT and I'm just going around in circles. Thanks! 
Categories:
  • Suggested answer
    David_MA Profile Picture
    15,512 Super User 2026 Season 2 on at
    Your post intrigued me because I need to do something similar to get information from FedEx shipment notifications. So, I tried to get the data out of the body of your HTML to text action since that is what I will need to do. I cannot guarantee this will work, but I managed to get the value you wanted:
    This is how I went about it, which assumes the e-mails are in a consistent format since the body of the message says do not reply:
    1. Return just the body value from what you show above. For my test, I just copied and pasted your text into a compose action.
    2. The first thing we then need to do once we have the body of the e-mail is to replace the double returns (\n\n) with a single return (\n) and get rid of all the asterisks and trim any leading and trailing spaces. We can do that with this expression: trim(replace(replace(outputs('Compose'),'\n\n','\n'),'*',''))
    3. Next, we want to split the output on the returns, which can be done with this expression: split(outputs('Compose_Replace_Double_Returns'),'\n')
    4. This will give us array of items with one item for each sentence in the e-mail.
    5. Next, I filter the array to only return the row with the booking reference number. I used a filter where the item (row) contains "https://mqb.-app.com".
    6. Now that I have the row with the data I want, it is rather easy if this is always formatted as shown above in the screen shot (the booking number, followed by a space and then the URL). I can use this expression to extract the value: first(split(first(body('Filter_array')),' '))
      1. Working inward to outward on the expression:
        1. first(body('Filter_array') gets the first item from the filter.
        2. split creates a new array on the space between the booking number and the URL.
        3. first then gets the first value from the split, which will be the booking reference number.
    The flow then looks like this:
    All of the actions are compose actions except for the filter array action.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 227 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 213 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 151

Last 30 days Overall leaderboard