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

Parse text from email attachment and add row into spreadsheet

(0) ShareShare
ReportReport
Posted on by

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
    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
    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

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

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard