1

Hi I am trying to send multiple images from my google drive via a script but the code does not seem to work. How can I achieve this?

function sendEmail() {

    var Rainfall = DriveApp.getFilesByName('beach.jpg')
    var High     = DriveApp.getFilesByName('High.png')

    MailApp.sendEmail({
    to:"example@google.com", 
    subject: "Images for Social Media", 
    body:"Hi Joe, here are the images for Social Media",


    attachments: [Rainfall.next(),High.next()]



  })

}
Mogsdad
  • 44,709
  • 21
  • 151
  • 275

1 Answers1

4

Finally got my hands to Google App Script editor. This variant defenitly worked and send me email with two attacments

function sendEmail() {

var Rainfall = DriveApp.getFilesByName('Untitled document')
var Rainfall2 = DriveApp.getFilesByName('128x128_tl_icon.png')

MailApp.sendEmail({
to:"mymail@gmail.com", 
subject: "Images for Social Media", 
body:"Hi Joe, here are the images for Social Media",


attachments: [Rainfall.next(), Rainfall2.next()]
  })

}
sendEmail()

Just make sure that files 'Untitled document' and '128x128_tl_icon.png' exists on your Google Drive. It think this is your problem

ShockwaveNN
  • 2,227
  • 2
  • 29
  • 56
  • thanks for the help, it worked. What is amazing is that both our scripts are exactly the same, the difference is the last sendEmail() which basically calls the method to send the same email again. I am not sure why mine wasn't working earlier because I made sure that the images I am trying to send were stored in my Google drive. – Molulaqhooa Maoyi Oct 02 '13 at 21:38
  • Last line not call the method again! Last line calls method for the first time. Without this line there is no call for this function and it just not starting to execute – ShockwaveNN Oct 03 '13 at 06:34