[英]Google apps script sends email with attached jpg file in google drive
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. 我正在tryinh从Google云端硬盘发送带有jpg文件的电子邮件,但是它不起作用。 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. 在此Google文档中 ,
attachments
参数应为BlobSource[]
类型,并且是与电子邮件一起发送的文件数组。
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! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.