Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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()]



  })

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
716 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...