I am using Google Apps Script (*.gs) to send mail via Gmail. Mails are working file and even attachments using images available in public URL are working fine. I am using
var file = DriveApp.getFileById("Google file ID")
to get the file and attach. I am getting the error
The feature you are attempting to use has been disabled by your domain administrator.
I am the admin and want to understand exactly where do I enable this feature. Can someone guide me please.
Addtionally, I checked my Google script Code's project properties and found that the following 4 OAuth Scopes are required by the script: Here are the scopes and next to them the response when I try accessing these in my browser.
- https://mail.google.com/
-- Able to access mails. - https://www.googleapis.com/auth/drive
-- The text "drive" appears in the top of the browser - https://www.googleapis.com/auth/script.external_request
-- The page gives error "Not Found. Error 404" - https://www.googleapis.com/auth/spreadsheets.currentonly
-- The page gives error "Not Found. Error 404"
Here are 3 scenarios I have tried. the 3rd one fails.
- Send mail without any attachment: WORKS PROPERLY.
function SimpleMail(){
GmailApp.sendEmail(<recipient email>, 'MAIL without any ATTACHMENT',
'Hi, \nPlease see mail without any attachment' )
}
- Send mail with attachment from a public URL: WORKS FINE with Attached image.
function sendAttachment(){
var attachmentUlr = "<URL of an Image on a public facing website>" ;
var fileBlob = UrlFetchApp
.fetch(attachmentUlr)
.getBlob()
.setName("fileBlob"+'.jpg');
GmailApp.sendEmail(<recipient email>, 'MAIL with ATTACHMENT',
'Hi, \nPlease see mail with image from a website as attachment', {attachments:[fileBlob]})
}
- With attachment from my Google Drive URL: FAILS,
function sendAttachment(){
var attachmentUlr = DriveApp.getFileById('<Google File ID>');
var fileBlob = UrlFetchApp
.fetch(attachmentUlr)
.getBlob()
.setName("fileBlob"+'.xlsx');
GmailApp.sendEmail(<recipient email>, 'MAIL with ATTACHMENT',
'Hi, \nPlease see mail with file from Drive as attachment', {attachments:[fileBlob]})
}