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 / Parse text from email ...
Power Automate
Answered

Parse text from email attachment and add row into spreadsheet

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

I am getting regular (every 30 mins) automated emails with a .txt file attached consisting of data that I want to be automatically entered into a spreadsheet. The .txt file has the same format every time and looks like this:

 

 

NS;5247
Su;6163

(2 rows affected)

 

 

 

and the body of the email looks like this:

 

 

Here is the report for 12/08/2021 10:55:33

 

 

 

What I want to do is enter this data into a new row on a spreadsheet every time I get a new email (with the same sender/subject every time), so that the data from every email is inputted into the spreadsheet in this format below. 

 

TypeCountDateTime
NS524712/08/2021 10:55:33
Su616312/08/2021 10:55:33

 

Additionally, I have a lot emails already sent to me that have this data but are not entered into the spreadsheet, would it be possible to create a flow that enters the figures from the previous emails into a spreadsheet? However, this is not as important as the previous issue as I can do this manually.

 

Thanks in advance

Categories:
I have the same question (0)
  • Verified answer
    fchopo Profile Picture
    8,003 Moderator on at

    Hi,

    In this excellent post it's explained how to extract data from txt file: Solved: Txt file to Excel table - Power Platform Community (microsoft.com)

    In any case, you could do something like this:

    1) When you receive an email with a specific subject:

    2) Initialize a variable with a line break

    3) For each attachment in the email

    3.1) Get the attachment and get all the lines:

    split(body('get_attachment_(v2)'),variables('lines'))

    3.2) For all the lines

    3.2.1) Get fields Type and Count using :

    split(item(),';')[0]

    or [1] according to the position in the text file.

    3.2.2.) Create an Excel row.

    excel-row.png

     

    Hope it helps!

    Ferran

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi,

     

    This seems to be the correct approach, but I am getting an error when testing this flow:

    trent_lim_0-1638996577801.png

     

  • fchopo Profile Picture
    8,003 Moderator on at

    Please, review the parameters in the Get Attachment (v2) action.

    Regards,

    Ferran

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hey Ferran,

     

    I have figured out the issue. I needed to put the attachment content into a string variable so that it would input the plaintext into the spreadsheet instead of the attachment's contentbytes. Here is my approach:

     

    trent_lim_0-1639080879733.png

     

    But your answer was really helpful, so I'll mark it as the solution.

  • dauc21 Profile Picture
    2 on at

    Hi @Anonymous, 

     

    Can you help me on how to put the content of the attachment into a string variable? Because I try this way, but I can only extract the content in bytes. I am unable to extract the contents of the string from the attached file.

     

     

    dauc21_0-1658879756789.png
    dauc21_1-1658879862137.png

    dauc21_2-1658879913603.png

     


     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard