0

I have tried multiple resources to look for a way that emails my google sheet as an attachment using appscript. Upon using the code below I can only send it out as a pdf.

function excelemail()

{ var file = DriveApp.getFileById('1Mytzfrl159TLMjMupziSKOrRJadsPKSLxYtaAvZTWt0');

GmailApp.sendEmail('shrikant.ravi@droom.in', 'Attachment example', 'Please see the attached file.' , {attachments: [file], name: 'Automatic Emailer Script' }) }

doubleunary
  • 13,842
  • 3
  • 18
  • 51
  • As google sheets is a collaborative tool, you should rather give by email the url of your spreadsheet and give the permissions – Mike Steelson Jun 21 '22 at 07:30
  • It is unclear which format you want to send the spreadsheet as. To send a link to a Google Sheet, use **File > Share**. To automate that, use [File.addEditor()](https://developers.google.com/apps-script/reference/drive/file#addEditor(String)), then email the link. – doubleunary Jun 21 '22 at 07:32
  • @doubleunary I wanna be able to send the attachment as an xlsx. apologies for not stating it above – Shrikant Ravi Jun 21 '22 at 10:09
  • @NEWAZA this code works well, also not sure of this is the right place to ask this ... is there a way I could add a cell range to the body of the email ...so that it shows up like a table in the body of the email.. i tried using {{sheetname!range}} within the the code it does not seem to work .. – Shrikant Ravi Jun 23 '22 at 05:30
  • See [Apps Script at Stack Overflow](https://stackoverflow.com/tags/google-apps-script/info). Please ask only [one question per post](https://meta.stackexchange.com/a/222741). – doubleunary Jun 23 '22 at 08:37

0 Answers0