I'm trying to attach a Google Docs file to an email using Google App Scripts. I have a folder with the file inside and the idea is to get the file from there and send it by email using also an email address that is saved in a google sheet.
I founded and used this:
function emailDocTestasDocx() {
var id = '1egjazIip6zuPneKh2sVFTvbK06asd4ZgAvrgjw';// an example of Google doc
var url = 'https://docs.google.com/document/d/1egjaasdasdeKh2sVFTvbK06z4JbPqnm4ZgAvrgjw';
var doc = UrlFetchApp.fetch(url);
var me = Session.getEffectiveUser().getEmail();
MailApp.sendEmail(me, 'test', 'see attachment', {attachments:[doc]});
}
It works but the final attachment is an html that redirects me to the doc inside the folder. I don't want that. I want to send the attachment but I didn't found a way to to this yet.
Any ideas? Thanks!