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 Apps / Create csv file and se...
Power Apps
Unanswered

Create csv file and sent as attachment

(0) ShareShare
ReportReport
Posted on by 997

Hello,

I got an email with my code

But still not attachment inside?

What do i wrong

Thank you

 

 

ClearCollect(
 CSVCollection;
 Concatenate(
 "Title,Item,Price";
 "\n";
 Concat(
 colCartData;
 Concatenate(
 "Title";
 ",";
 "field_1";
 ",";
 "field_9";
 "\n"
 )
 )
 )
);;

SMTP.SendEmailV3(
 {
 To:"demo@email.com"; 
 Subject:"Test subject csv";
 Body:"hi, you have a copy of the csv file";
 attachments: Table(
 {
 FileName: "myCSVfile.CSV";
 ContentData: Concat(CSVCollection; ",");
 ContentId: "1";
 ContentType: "application/octet-stream"
 }
 )
 }
)

 

 

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

    Try something like this:

    ClearCollect(
     CSVCollection;
     Concat(
     colCartData;
     ThisRecord.Title & "," & ThisRecord.field_1 & "," & ThisRecord.field_9 & "\n"
     )
    );
    
    // Add the column headers
    Set(
     CSVString;
     "Title,Item,Price\n" & CSVCollection
    );
    
    SMTP.SendEmailV3(
     {
     To:"demo@email.com"; 
     Subject:"Test subject csv";
     Body:"hi, you have a copy of the csv file";
     attachments: Table(
     {
     FileName: "myCSVfile.CSV";
     ContentData: CSVString;
     ContentId: "1";
     ContentType: "text/csv"
     }
     )
     }
    )

     

    Replace Title, field_1, and field_9 with the actual column names you have in your colCartData collection

  • TimmyBoy Profile Picture
    997 on at

    Hello @Rusk 

    Seems we have an error

    TimmyBoy_0-1689100518073.png

    TimmyBoy_1-1689100632409.png

     

    These are the actual column names 🙂

    colCartData;
     ThisRecord.Title & "," & ThisRecord.field_1 & "," & ThisRecord.field_9 & "\n"

      But sending the mail there is still no attachment

    TimmyBoy_0-1689100997712.png

     

  • TimmyBoy Profile Picture
    997 on at

    Hi @Rusk ,

    Okay, seems i got a part working 🙂

    I have the attachment

    TimmyBoy_1-1689209856168.png

    But when opening the csv, there is no data or even the Headnames

    TimmyBoy_0-1689209833734.png

    What do we wrong?

    Updated code:

    ClearCollect(
     CSVCollection;
     Concat(
     colCartData;
     ThisRecord.Title & "," & ThisRecord.field_1 & "," & ThisRecord.field_9 & "\n"
     )
    );;
    // Add the column headers
    Set(
     CSVString;
     "Title,Item,Price\n" & Concat(CSVCollection;Value)
    );;
    
    SMTP.SendEmailV3(
     {
     To:"demo@mail.com"; 
     Subject:"Enter email subject here";
     Body:"Enter email body here";
     Attachments: Table(
     {
     FileName: "myCSVfile.CSV";
     ContentData: CSVString;
     ContentId: "1";
     ContentType: "text/csv"
     }
     )
     }
    )

     

     

  • Rusk Profile Picture
    1,369 Super User 2024 Season 1 on at

    Maybe it's because "ThisRecord.Title" is being used, instead of a specified column name?  Not sure... we can try this:

    ClearCollect(
     CSVCollection;
     Concat(
     colCartData;
     Title & "," & field_1 & "," & field_9 & "\n"
     )
    );;
    // Add the column headers
    Set(
     CSVString;
     "Title,Item,Price\n" & Concat(CSVCollection;Value)
    );;
    
    SMTP.SendEmailV3(
     {
     To:"demo@mail.com"; 
     Subject:"Enter email subject here";
     Body:"Enter email body here";
     Attachments: Table(
     {
     FileName: "myCSVfile.CSV";
     ContentData: CSVString;
     ContentId: "1";
     ContentType: "text/csv"
     }
     )
     }
    )
    
  • TimmyBoy Profile Picture
    997 on at

    Hi @Rusk 

    Sorry, same result

    The csv file is empty

    TimmyBoy_0-1689294674141.png

    This is the result in my collection

    TimmyBoy_1-1689294774543.png

    There is data, but nothing happening in the csv?

    Can you help me further please?

    Thanks

  • TimmyBoy Profile Picture
    997 on at

    Hello,

    It's been a few month i asked this question

    And still i didn't managed to fix this issue

    How can i fill the contentData to my filename
    Because my file myCSVfile.CSV is always empty.

    Attachments: Table(
     {
     FileName: "myCSVfile.CSV";
     ContentData: myCSV;
     ContentId: 1;
     ContentType: "text/csv"
     }

    Create the csv contents:

    UpdateContext(
     {
     myCSV:
     "NAME1;NAME2;NAME3;NAME4" & Char(10) &
     Concat(
     colmycsvData;
     Title & ";" & field_1 & ";" & field_2 & ";" & field_3 & Char(10)
     )
     }
    );;

    Thank you

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard