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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get Certain informatio...
Power Automate
Unanswered

Get Certain information in email and send it to teams chat

(0) ShareShare
ReportReport
Posted on by 4

Hello, I've been playing around with power automate and really found some useful case within my team. So we've been receiving hundreds or thousands of emails of system alerts and want to filter the most important ones to send it to teams chat. The email is in Rich Text format and not HTML.

 

So sample email is:

# Organization = BLA BLAH

# Machine Address = USA

# Machine City = BLA BLAH

# Machine State = BLA BLAH

# Machine Zip = BLA BLAH

# Machine Country = BLA BLAH

# Contact Name = BLA BLAH

# Alternate Contact Name = BLA BLAH

# Contact Phone Number = BLA BLAH

# Alternate Contact Phone Number = BLA BLAH

# Offshift Phone Number = N/A

# Alternate Offshift Phone Number = N/A

# Contact Email = BLA BLAH

# Machine Location = BLA BLAH

# Record Type = BLA BLAH

# Machine Type = BLA BLAH

# Serial Number = BLA BLAH

# Machine Part Number =

# Component =

# Component Release =

# Group Name =

# Hardware MT =

# Hardware SN =

# Error ID = FAILED HARDWARE

# Error Code = BLA BLAH BLA BLAH BLA BLAH

# Error Type = software

# System Version = SystemVersion

# FRU = None

# System Name = SystemName

 

And I want to get only the following lines or information to send to teams chat:
# System Name = SystemName
# Error ID = FAILED HARDWARE
# Error Code = BLA BLAH BLA BLAH BLA BLAH

 

and other information if required.

Categories:
I have the same question (0)
  • kacaforyah Profile Picture
    19 on at

    Using a 'When an email is received' trigger you can use an expression like this for # Error ID

     

    substring(triggerbody(), add(indexof(triggerbody(),'# Error ID ='),14), sub(nthindex(substring(triggerbody(), indexof(triggerbody(),'# Error ID =')),'#',2),1))

     

    Let's break down this expression:

    1. triggerbody(): This presumably gives the entire content of the email or whatever trigger you have set up in Power Automate.

    2. indexof(triggerbody(),'# System Name ='): This finds the starting position of the text # Error ID = in your email content.

    3. add(indexof(triggerbody(),'# Error ID'),10): This gives the position right after# Error ID (since # Error ID = is 10 characters long). This should be the starting position of the actual system name in your email content.

    4. substring(triggerbody(), indexof(triggerbody(),'# Error ID')): This would give you the content of the email starting from # Error ID = till the end.

    5. nthindex(...,'#',2): This nthindex is a function you're using to return the position of the second occurrence of # from the substring derived in the previous step.

    6. sub(nthindex(...),'#',2),1): This is to subtract 1 from the position obtained in the previous step.

    7. The entire substring function, then, would try to extract the string starting from right after # Error ID = and ending just before the next #.

    -----

    For System name because nothing comes after, you can use this expression:

    substring(triggerbody(), add(indexof(triggerbody(),'# System Name ='),14))

  • heprex Profile Picture
    4 on at

    Thanks! let me play with it a bit more as I'm new to this. kept getting this error

    inputs at line '0' and column '0': 'The template language function 'indexof' expects its first parameter to be of type string. The provided value is of type 'Object'.

  • kacaforyah Profile Picture
    19 on at

    You can look at the output of your trigger runs and see what the exact property name is for the content. Might be like triggerbody()['content'] or triggerbody()['body']. If that doesnt work try casting it as a string:

    substring(string(triggerbody()), add(indexof(string(triggerbody()),'# Error ID ='),14), sub(nthindex(substring(string(triggerbody()), indexof(string(triggerbody()),'# Error ID =')),'#',2),1))

     

  • heprex Profile Picture
    4 on at

    Thank you. Manage to make it work. But some follow up question, how about if the next line doesn't start with "#"?

  • kacaforyah Profile Picture
    19 on at

    From the sample that only happens at the end right? If there's nothing after that in the input, then you can use

     

    substring(string(triggerbody()), add(indexof(string(triggerbody()),'# System Name ='),16))

     

    Which will return everything after system name =. 

     

    Alternatively, you can change the index character. If it's some html code then you can change that '#' to whatever is next in your data. And change the nthindexof function to indexof, which will return the first index of the character by default.

    Heres what it looks like:

    substring(string(triggerbody()), add(indexof(string(triggerbody()),'# System Name ='),16), sub(indexof(substring(string(triggerbody()), indexof(string(triggerbody()),'# System Name =')),'your character goes here'),1))

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard