您好我在发送带有图片附件的电子邮件时遇到了麻烦。因为图像文件名是随机的,无法确定我的消息正文是否适合它将从我的驱动器发送的图像。以下是我所做过程的一步一步:
示例:
function send() {
var picture1 = DriveApp.getFilesByName('snottyboy.jpg');
var picture2 = DriveApp.getFilesByName('daryl.jpg');
var recipientsTO = "fgh@gmail.com" + "," + "sdd@gmail.com"+ "," + "spaz@gmail.com"+ "," + "def@gmail.com"+ "," + "abc@gmail.com";
MailApp.sendEmail({
to:recipientsTO,
subject: "LOOK A LIKE",
body:"Final Message",
attachments: [picture1.next(),picture2.next()]
});
}
感谢您的帮助。
答案 0 :(得分:2)
要附加文件,请使用int[] seq= new int[10];
var seq2= new List<int>();
for (int i = 0; i < seq.Length; i++)
{
Console.WriteLine("Add number ");
seq[i] = int.Parse(Console.ReadLine());
if (seq[i]%2==0)
{
seq2.Add(seq[i]);
}
}
for (int i = 0; i < seq2.Count(); i++)
{
Console.WriteLine(seq2[i]);
}
将其附加为File.getBlob()
。例如:
blob
如果您知道文件的确切ID(例如&#39; 0BxDqyd_bUCmvN1E3N0dQOWgycEF&#39;),您可以像attachments: [picture1.next().getBlob(),picture2.next().getBlob()]
那样得到它:
blob
这是一个有效的例子:
var picture3Blob = DriveApp.getFileById('0BxDqyd_bUCmvN1E3N0dQOWgycEF').getBlob();
这里是一个内联而非附件的图片示例:
function sendPics() {
var picture1 = DriveApp.getFileById('0BxDqyd_bUCmvN1E3N0dQOWgycFE'); //public with link
var picture2 = DriveApp.getFileById('0BxDqyd_bUCmvTFNjRkRXbXA2Tms'); //public with link
MailApp.sendEmail({
to: 'testa@example.com, testb@example.com',
subject: "This is a test",
body:"Test message",
attachments: [picture1.getBlob(), picture2.getBlob()]
});
}