I wrote a function to share files automatically with users using google apps script. However, I want to add a custom message while sharing (like we do with manual sharing). I want this so that I don't have to send emails to the users separately. I was initially sending email along with file url but the email was blocked (since message contained links). Is there a way to add custom message?
function fileshare(url, email) {
var f = SpreadsheetApp.openByUrl(url);
var id = f.getId();
try{
//f.addViewer(email);
DriveApp.getFileById(id).addViewer(email);
}
catch (e) {
Logger.log("File could not be shared, please check if email address is valid");
}
}