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 / How to extract the sec...
Power Automate
Unanswered

How to extract the second line from an email body?

(0) ShareShare
ReportReport
Posted on by 10

Hi, I'm hoping someone can help.

I'm trying to extract the first and second lines of an email body and insert them into two separate columns in excel.

I followed the answer from the following post to extract the first line (https://powerusers.microsoft.com/t5/Building-Flows/Extract-first-line-of-email-body/td-p/545440# ) which works but, i've not been able to find anything to help me extract the second line.

 

The contents of the first line could be any length (but currently a maximum of 11 characters) and the second line could be any number of characters with no limit.

 

FYI - i'm a complete newbie to this and coding in general so any really basic step by step help (similar to that of the guidance in the link above) would be incredibly appreciated.

 

Thank you!

Categories:
I have the same question (0)
  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    hi @magicwas  please try to paste your body content here

  • magicwas Profile Picture
    10 on at

    hi @ChristianAbata , thank you for your response.

     

    The body content would simply be a forwarded email of some sort but in the body of the new email that will be forwarded will just be two lines. The first line will have a word to describe the email being forwarded and the second line will have a name.

     

    The idea is to log work coming in and to allocate it someone while keeping track of that allocation within a spreadsheet.

     

    the body preview would simple be:

     

    Marketing

    John Smith

     

    From: [NAME]

    Sent: [DATE]

    To: [EMAIL ADDRESS]

    Subject: xxxx

     

    [whatever is forwarded]

     

    I hope that makes sense. Let me know if you need anything else.

    Really appreciate your help.

  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    Shure @magicwas  you said that you need to optain the second line of the body email but in your example you add me fields like 

    From: [NAME]

    Sent: [DATE]

     

    So, you are trying to get the second line from a message forwarded?

  • magicwas Profile Picture
    10 on at

    Hi @ChristianAbata,

    Sorry if i'm not articulating this clearly - its all new terminology for me!

    The 'From' and 'Name' were just to demonstrate that this would be the forwarded emails that would follow after the two lines i wish to extract. In my example, I would only want to extract the first two lines of the email, 'Marketing' and 'John Smith', everything that appears after that would be the previous emails in the email chain and can all be ignored.

     

    I hope that makes more sense.

     

    Thank you again for your persistence!

  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    ok, just another question @magicwas  in your emails, you are going to receive allways 'Marketing' and 'John Smith or this is just and example and your content allways is going to be different?

  • magicwas Profile Picture
    10 on at

    Hi @ChristianAbata,

    Thank you again for your reply.

    No, 'Marketing' and 'John Smith' are just examples. What will actually be written could be anything but one will always be on the first line and the other will always appear on the second line.

  • Verified answer
    yashkamdar Profile Picture
    1,044 on at

    Hello Team,

     

    Here is how you get the first and the second line of your email body.

     

    Step 1 - Initialize a variable, enter the Type as STRING.

    Do not forget to hit an ENTER in the Value of the Intialize a variable action.

    Basically just go the Value field of the action "Initialize Variable" and hit an enter once in the body area.

     

    yashkamdar_0-1599505296116.png

     

     

    Step 2 - Compose

     

    As shown in the image below, create a COMPOSE action and add Body preview as Inputs.

    yashkamdar_2-1599505473739.png

     

     

    Step 3 - Compose action with expression

     

    Enter the following expression in COMPOSE action to get the first line of the email.

     

    split(outputs('Compose'),variables('ParseEmail'))[0]

     

    yashkamdar_3-1599505675556.png

     

     

    Step 4 - Compose action with expression

     

    Similarly you need to add another compose action to get the second line

     

    split(outputs('Compose'),variables('ParseEmail'))[1]

     

     

    If there is a space between your first line of the email and the second line then the above expression changes to -

    split(outputs('Compose'),variables('ParseEmail'))[2]

     

     

     

    Input email-

     

    Capture.PNG

     

     

    Outputs-

     

    Capture.PNG

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

     

     

  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    @magicwas  please try this...

     

    fas.PNG

  • magicwas Profile Picture
    10 on at

    Thank you @ChristianAbata  and @yashkamdar for all your help!

    They both worked perfectly. I ended up going with @yashkamdar's solution as it was already so close to the solution that i used to extract the first line as was a matter of changing one digit to get the second line (not sure why i didnt think of that myself!)

     

    thank you both again for all your help 🙂

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard