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 / Get Email Attachment C...
Power Automate
Unanswered

Get Email Attachment CSV Contents

(0) ShareShare
ReportReport
Posted on by 114

I have built a flow that when a new email arrives, get the attachment. This is working successfully.

 

How can I read the contents of the attached email and send these to a SP list? I already have the SP list created and have created columns names to match. My issue is that I am not sure sure to parse the csv file.

 

The attachment is a csv file and the contents are below.

 

Date,"row 1","row 2","row 3","row 4","row 5"
2023-12-14,155,1,31,4,114

 

Using a premium connector is not an option.

Categories:
I have the same question (0)
  • Matthy79 Profile Picture
    4,180 Super User 2024 Season 1 on at

    Hello @jonboylib 

     

    You could use a third party connector or use split to manually read the csv. You will find a lot of topics reading csv in this forum. (Avoid loop solutions)

  • jonboylib Profile Picture
    114 on at

    Thanks @Matthy79 but as I said, I'm unable to use premium connectors, should have also said third party ones.

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Hopefully this is what you're after. This assumes that you don't have any commas within the actual values and that you already know the columns in the CSV attached.

     

    For this example, I've go the following CSV file attached to my email.

    grantjenkins_0-1702730939189.png

     

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_4-1702731404724.png

     

    When a new email arrives gets the email and attachments. I've set it to Include Attachments and Only with Attachments, plus a Subject Filter.

    grantjenkins_2-1702731272347.png

     

    Apply to each iterates over each of the Attachments.

    grantjenkins_3-1702731372447.png

     

    Filter array uses the following expression to extract out each of the rows of data, skips the first row (headers), and removes any empty rows.

    //From
    skip(
     split(
     base64ToString(items('Apply_to_each')?['contentBytes']),
     decodeUriComponent('%0D%0A')
     ),
     1
    )
    
    //Condition
    trim(item())
    

    grantjenkins_5-1702731547093.png

     

    Apply to each row iterates over each of the rows from the Filter array.

    grantjenkins_6-1702731582440.png

     

    Create item uses the following expressions to add a new item to the SharePoint List. Note that I didn't know what you wanted to do with the Title column, so just left it blank in this example.

    split(item(), ',')?[0]
    split(item(), ',')?[1]
    split(item(), ',')?[2]
    split(item(), ',')?[3]
    split(item(), ',')?[4]
    split(item(), ',')?[5]

    grantjenkins_7-1702731649544.png

     

    After running the flow, we would have the following output.

    grantjenkins_8-1702732212173.png

  • jonboylib Profile Picture
    114 on at

    Thanks @grantjenkins 

     

    I have followed your instruction and at the first step mine looks very different, see below.

     

    I added the trigger 'When a new email arrives', then I added the action 'Get attachment'. When I populate this action with the Message Id and Attachment ID the flow automatically generates three for each blocks, why? I haven't proceeded with the rest of the steps because it look so different to your flow. 

     

    em1.jpg

  • grantjenkins Profile Picture
    11,063 Moderator on at

    If you look at my flow, I haven't used the Get attachment, Message Id or Attachment ID. If you follow what I have it should work as expected.

  • jonboylib Profile Picture
    114 on at

    Thanks @grantjenkins I missed that part!

     

    My flow appears to be adding an additional For Each - not sure why.

     

    Also, my filter array inputs and outputs are empty.

     

    em2.jpg

    When i click the Apply to each action, the INPUTS are;

     

    [
    {
    "@odata.type": "#microsoft.graph.fileAttachment",
    "id": "AAMkADYxNmMyODQTIRe06OimXLyBwDodsBvY28-SYMgdvh-4=",
    "lastModifiedDateTime": "2023-12-18T11:05:30+00:00",
    "name": "report.csv",
    "contentType": "application/csv",
    "size": 527,
    "isInline": false,
    "contentId": "12BBF8FDDE260380C79DD@eur.prod.outlook.com",
    "contentBytes": "RGF0ZSwiU3R1ZGVudCByZWNvcmRzIHVCIsIlN0YWZmIHVwZGF0ZXMksMTMsMjE3Cg=="
    }
    ]

     

    I've used the exact code you provided.

     

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