Skip to main content
edited tags
Link
added 51 characters in body
Source Link
user0
  • 27.1k
  • 10
  • 53
  • 78

Could anyone help me?

I've created a google formGoogle Form that uploads a file (image) to a private drive folder, the form also sends responses to a google sheetGoogle Sheet including the image's urlURL. The code below gets the file id and sends the image as an attachment but it doesn't do it in the body of the email. The folder must be private.

function sendImage(){ var sheet = SpreadsheetApp.getActive().getActiveSheet(); var fileUrl = sheet.getRange('C2').getValue(); var index = fileUrl.indexOf('=') + 1; var fileId = fileUrl.substring(index); var img = DriveApp.getFileById(fileId).getBlob();

MailApp.sendEmail({ name: "my Name", to: '[email protected]', subject: "Test 1", body: img, attachments: img, }); }

function sendImage(){
  var sheet = SpreadsheetApp.getActive().getActiveSheet();
  var fileUrl = sheet.getRange('C2').getValue();
  var index = fileUrl.indexOf('=') + 1;
  var fileId = fileUrl.substring(index);
  var img = DriveApp.getFileById(fileId).getBlob();

 MailApp.sendEmail({
    name: "my Name",
    to: '[email protected]',
    subject: "Test 1",
    body:  img,
    attachments: img,
     });
}

Could anyone help me?

I've created a google form that uploads a file (image) to a private drive folder, the form also sends responses to a google sheet including the image's url. The code below gets the file id and sends the image as an attachment but it doesn't do it in the body of the email. The folder must be private.

function sendImage(){ var sheet = SpreadsheetApp.getActive().getActiveSheet(); var fileUrl = sheet.getRange('C2').getValue(); var index = fileUrl.indexOf('=') + 1; var fileId = fileUrl.substring(index); var img = DriveApp.getFileById(fileId).getBlob();

MailApp.sendEmail({ name: "my Name", to: '[email protected]', subject: "Test 1", body: img, attachments: img, }); }

Could anyone help me?

I've created a Google Form that uploads a file (image) to a private drive folder, the form also sends responses to a Google Sheet including the image's URL. The code below gets the file id and sends the image as an attachment but it doesn't do it in the body of the email. The folder must be private.

function sendImage(){
  var sheet = SpreadsheetApp.getActive().getActiveSheet();
  var fileUrl = sheet.getRange('C2').getValue();
  var index = fileUrl.indexOf('=') + 1;
  var fileId = fileUrl.substring(index);
  var img = DriveApp.getFileById(fileId).getBlob();

 MailApp.sendEmail({
    name: "my Name",
    to: '[email protected]',
    subject: "Test 1",
    body:  img,
    attachments: img,
     });
}
Source Link
Eddyn
  • 33
  • 1
  • 1
  • 3

How do I insert an image from Google Drive into email body with script

Could anyone help me?

I've created a google form that uploads a file (image) to a private drive folder, the form also sends responses to a google sheet including the image's url. The code below gets the file id and sends the image as an attachment but it doesn't do it in the body of the email. The folder must be private.

function sendImage(){ var sheet = SpreadsheetApp.getActive().getActiveSheet(); var fileUrl = sheet.getRange('C2').getValue(); var index = fileUrl.indexOf('=') + 1; var fileId = fileUrl.substring(index); var img = DriveApp.getFileById(fileId).getBlob();

MailApp.sendEmail({ name: "my Name", to: '[email protected]', subject: "Test 1", body: img, attachments: img, }); }