function pic() { var userEmail = "sikrarin.pooh@gmail.com"; var firstName ="test"; var Subject = "test" var file = DriveApp.getFileById('0B1j-ntZn6vurRkZVVEpxWmRGSlU'); MailApp.sendEmail({ to: userEmail, subject: Subject, attachment:[file,blob] }) }
I am tryinh to send an email with a jpg file from google drive, but it doesn't work. Help me please.
From this Google documentation , attachments
parameter should be BlobSource[]
type and it's an array of files to send with the email.
Example from the documentation:
// Send an email with two attachments: a file from Google Drive (as a PDF) and an HTML file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var blob = Utilities.newBlob('Insert any HTML content here', 'text/html', 'my_document.html');
MailApp.sendEmail('mike@example.com', 'Attachment example', 'Two files are attached.', {
name: 'Automatic Emailer Script',
attachments: [file.getAs(MimeType.PDF), blob]
});
Check if this code will work for you:
function pic()
{
var userEmail = "sikrarin.pooh@gmail.com";
var firstName ="test";
var Subject = "test"
var file = DriveApp.getFileById('0B1j-ntZn6vurRkZVVEpxWmRGSlU');
MailApp.sendEmail(userEmail, Subject{
attachment:[file,blob]
});
}
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.