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 / Extract text from email
Power Automate
Unanswered

Extract text from email

(0) ShareShare
ReportReport
Posted on by 118

Hi Everyone,


I tried many alternatives but cannot get this to work, but it isn't working.

 

I receive emails from the Ministry (attached) and I am trying to extract information from that email into an excel table. Because my fields are not as obvious, it makes it a bit harder. For example, the format is not Name: John Smith, instead it is Hello John Smith.

I tried different actions like regex to recognize and extract patterns, but did not work. Any help would be appreciated.

 

These are the fields I am looking to extract:
Name, College, Campus, Class_name, Level, Class_number, Start_date, End_date, Type, MOD

 

V2.png
Screenshot 2023-11-14 154838.png
Categories:
  • Rhiassuring Profile Picture
    8,692 Moderator on at

    Are you able to copy / paste / attach the email body (anonymized of course) into the chat? We'd need to see how the body comes through.

     

    In this scenario, since I bet it's coming through the same every time, I'd probably just split on some stuff and then count where the selections should be. But hard to tell without access to the email itself to see how it operates.

  • soy Profile Picture
    118 on at

    When I paste the code, it's all in one paragraph. I attached a PDF, does that work?

     

    Thanks for your help. 

  • soy Profile Picture
    118 on at

    Yes, every email is identical in regards to formatting, where names are, etc. I attached a PDF in your other reply.

  • Rhiassuring Profile Picture
    8,692 Moderator on at

    Hmm ... I don't think the PDF will help. 

     

    If you could get Power Automate to pick it up and give us the anonymized output, that'd probably work. Ie, forward the email to yourself, have a Power Automate flow that picks up "when an email is received", and then the output from that trigger should have what we need in it.

  • soy Profile Picture
    118 on at

    My issue is that Power Automate is not picking up any data.

     

    Would this work?


     

    Offer of Classroom Training

     

     

    Hello Zyad Suleiman,

    The Ministry of Labour, Immigration, Training and Skills Development would like to offer you a classroom seat at the college/training centre below. 

    Seats are limited and reserved on a first-come, first-serve basis when you pay your fee. Please contact the college/training centre as soon as possible to secure your spot in the class.

     

     

     

    College/training centre information

     

    Algonquin College of Applied Arts & Tech

    Woodroffe Campus

    1385 Woodroffe Avenue, Ottawa, ON, K2G1V8, ,

     

    soy_0-1700056672397.png

     

     Email Us

     

    soy_1-1700056672399.png

     

     613-727-7662  

     

    Class information

     

    Class name

     

    Electrician - Construction and Maintenance

     

    Level

     

    5

     

    Class number

     

    2254891

     

    Start date

     

    January 18, 2024

     

    End date

     

    March 25, 2024

     

    Type

     

    Full-time

     

    Method of delivery

     

    Block

     

    Duration

     

    50 days

     

    Classroom fee

     

    $500.00*

     

    *Additional fees may apply to the classroom fee indicated above. Please contact the college/training centre to confirm the total cost.

     

     

     

    How do I enroll in the class?

     

     

    1

    Register and pay for this class using the information under Register and Pay.If no information is avaliable, please call or email the college/training centre using the contact information above.

      

    2

    Your college/training centre will provide you with information on class fees, refund policies, start time, room location, and directions to the campus.

      

    3

    You may be eligible for Employment Insurance or other types of income support. You can learn more about eligibility and on how to apply for income support while attending training. Once you have reserved your seat at the college/training centre, you will receive an enrolment confirmation letter from the Ministry containing the information required to apply for Employment Insurance.

      

     

    Register and Pay

    Register Online

     

    soy_2-1700056672399.png

     

     888-269-2762  

     

     

     

    Need more information?

    For more information, contact your Employment and Training Consultant below. If you do not have an Employment and Training Consultant and require more information, contact Employment Ontario or visit the Apprenticeship in Ontario website.

     

    Your apprenticeship information

     

    Client ID

     

    2948840

     

    Registered Training Agreement Number

     

    DND249198

     

    Sponsor/employer

     

    Target

    Employment and Training Consultant

     

    soy_3-1700056672400.png

     

     

    soy_4-1700056672400.png

     

     905-842-5105  

     

     

  • soy Profile Picture
    118 on at

    Hi there,

    I think native expression is the best, but don't know what tools to use. I see people using "compose" features, etc. What would something like this look like?

  • Rhiassuring Profile Picture
    8,692 Moderator on at

    Hi @soy 

     

    So, a few things. 

     

    First, you state that Power Automate is not picking up any data. To  have your flow work,  you'll need to set up an "When a new email is received.." trigger, and set the "Subject" to whatever this subject would be, so it doesn't run on every email. Looks like it's maybe "Offer of Classroom Training"? 

     

    Next, your email body.

     

    So this won't be exact, because the way the email arrives and displays may be different than what you've posted here. But, this should give you an idea of how I'd go about it:

     

    Rhiassuring_0-1700080906227.png

     

    The first Compose is just me pasting in your email so I can access it.

     

    Next, I'm creating a variable and just hitting "enter" in the value - that's so I can say "split everywhere you see an enter.

     

    Then, I'm doing just that - splitting the email based on the enter.

     

    The thing is: if your email is truly the same format every time, you can actually number the line in the array that you'll get your information. Let me show you what I mean.

     

    Here's a part of what it looks like when it's split:

     

    Rhiassuring_1-1700081028001.png

     

    Ugly, right? 

     

    Ugly, but functional, because we can now count the lines and access whatever line is needed.  Keep in mind that arrays start at 0. (0, 1, 2, 3..)

     

    So let's say we want the Class Name. I count the lines. That's line #49 (and when I say "line", I mean every set of ""s). So I can get it using this formula, in a Compose:

     

    outputs('Compose')[49] 

     

    And out it comes - I can place it in a variable instead, if I want:.

     

    Rhiassuring_2-1700081482337.png

     

    You'd repeat this action for everything you want to extract.

     

    Some notes:

     

    1) You need to make sure the email truly is the same every time.

    2) You need to trigger it based on the email itself, so you're using the right information to build from. Send yourself the email, to trigger / test it.

    3) You can remove blanks / spaces from it first, you can Filter Array for anything that's not null/a space, if you want. You don't really need to, but it'd make it easier to count the lines.

     

     

     

     

     

     

  • AlexEncodian Profile Picture
    4,409 Moderator on at

    @soy 

    Compose in Power Automate is used to save data that you want to use later in your flow. It’s a type of action that can be used to create an arbitrary object or temporarily store data for reference later in the flow, similar to variables in programming. And you can use expressions to create the value

    e.g. if you do a compose with input "1", then the output is "1". 

    e.g. if you do a compose with an input expression  "split(‘Hello, world!’, ‘,’)" then the output will be an array with two elements: [“Hello”, " world!"]

    Its sounds more complicated than it is but if you want to use native expressions, you need to train yourself up on this. 

    Parsing Email Text in Power Automate - Power Platform Community (microsoft.com)

  • soy Profile Picture
    118 on at

    Thanks for your time trying to help. So far, nothing is working.


    Can you tell me what I would do for step 3 (Then, I'm doing just that - splitting the email based on the enter.)

    - What would replace "Compose_-_Email) 

     

    Screenshot 2023-11-17 134943.png

  • Rhiassuring Profile Picture
    8,692 Moderator on at

    See my variable called txtLine - there's a big space in the field because I just clicked in there once, and pressed "Enter" on my keyboard. It holds a carriage return in a variable.

     

    Now on your split(), you'll be splitting the body of your email by that txtLine variable.

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 231 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 217 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 170

Last 30 days Overall leaderboard