Send an email with an attached file saved in a specific TeamDrive

17 views
Skip to first unread message

Andrea

unread,
May 27, 2019, 4:16:38 AM5/27/19
to Google Apps Script Community
Dear ones, I need your help.
I have this code that sends an email with an attached file. This file must be in the same drive as the script.

function sendEmails () {
var FileToSend = "MyFile.xls";
var Message = "Hello";
var Recipient = "reci...@mydomain.com";

var Subject = "SUBJECT"
var file = DriveApp.getFilesByName (FileToSend)
if (file.hasNext ()) {
var file = file.next ();
}

GmailApp.sendEmail (recipient, subject, message, {attachments: file});

}
};

I would like the script to take a file from TeamDrive "XXX". It's possible to do it?
I thank you for your precious help.

Andrea
Reply all
Reply to author
Forward
0 new messages