Skip to main content

Notifications

Power Automate - Building Flows
Suggested answer

Script to Parse HTML Emails

(0) ShareShare
ReportReport
Posted on by

Hello,

I am looking for an expression or script to use in my Power Automate flow. My flow converts email requests that are forwarded into Planner tasks. The Planner tasks include the body of the email in the description section.

The email may contain an email thread, i.e., multiple messages within the same email. I want to capture the name of the initial sender (i.e., the person who sent the first email in the thread) and the timestamp of the last email sent before it was forwarded to the shared mailbox.

I believe the best approach is to extract this information directly from the initial trigger of the flow (i.e., when an email arrives) or from the description portion of the task. The idea is to leverage the "FROM:" and "Sent:" fields in the email's HTML content to identify the initial sender and timestamp.

The expression I currently use does not consistently capture the originator or requester.

Any ideas or suggestions to improve this process would be greatly appreciated.

  • VictorIvanidze Profile Picture
    VictorIvanidze 11,853 on at
    Script to Parse HTML Emails
    Could you share your flow?
  • Suggested answer
    AlexEncodian Profile Picture
    AlexEncodian 4,302 on at
    Script to Parse HTML Emails
    Convert your email to string using "HTML to Text", pass the text through to Encodian's Utility - Extract Text Instances between Values which will extract all text instances between a start and end value. For example, you could use start value "FROM:" and end value: line break (if you dont have a better repeating character).

    This will give you an array of values for each email in the chain. Use the first() and last() operators to get the values corresponding to the last and first emails (note they will be in reverse order i.e. first() will give the from from the last email).

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard