Скриптът за приложения на Google изпраща имейл с прикачен jpg файл в google диск

function pic()
{

var userEmail = "[email protected]";
var firstName ="test";
var Subject = "test"
var file = DriveApp.getFileById('0B1j-ntZn6vurRkZVVEpxWmRGSlU');
MailApp.sendEmail({
to: userEmail,
subject: Subject,
attachment:[file,blob]

})
}

Опитвам се да изпратя имейл с jpg файл от Google Drive, но не работи. Помогнете ми моля.


person Sikrarin Tachaworapatana    schedule 07.07.2016    source източник


Отговори (1)


От тази документация на Google параметърът attachments трябва да бъде BlobSource[] и това е масив от файлове за изпращане с имейла.

Пример от документацията:

 // 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('[email protected]', 'Attachment example', 'Two files are attached.', {
     name: 'Automatic Emailer Script',
     attachments: [file.getAs(MimeType.PDF), blob]
 });

Проверете дали този код ще работи за вас:

function pic()
{

var userEmail = "[email protected]";
var firstName ="test";
var Subject = "test"
var file = DriveApp.getFileById('0B1j-ntZn6vurRkZVVEpxWmRGSlU');

MailApp.sendEmail(userEmail, Subject{
attachment:[file,blob]    
});

}

Надявам се това да помогне!

person abielita    schedule 07.07.2016