how to send email with csv/xls attachment

1,122 views
Skip to first unread message

Dmitry Z.

unread,
Jun 8, 2014, 4:16:31 AM6/8/14
to adwords...@googlegroups.com
I've the certain spreadsheet with the certain data.
I need to email the data from the spreadsheet as attachment in csv/excel format.

Here is code I use

 MailApp.sendEmail('my_e...@example.com', 'Attachment example',
                    'Two files are attached.',
                    {
                        name: 'Automatic Emailer Script',
                        attachments: [file.getAs('text/csv')]
                    });

But I got error, that application/pdf can't be converted to 'text/csv'.
How can I solve such task?

Best regards,
Dmitry


anash

unread,
Jun 23, 2014, 11:54:21 AM6/23/14
to adwords...@googlegroups.com
Hi Dmitry,

I believe that file variable holds a pdf right now. If you generate a Google Spreadsheet, then getAs("text/csv") then the code should work fine.

Cheers,
Anash P. Oommen,
AdWords Scripts Team.
Reply all
Reply to author
Forward
0 new messages