【发布时间】:2021-10-08 15:53:05
【问题描述】:
我遇到了应用脚本问题,我正在尝试下载粘贴在内容中的链接以进行驱动。
邮件示例如下
报告下载网址:xxxxxx.xlsx
上面的 xxxxx.xlsx 是我们下载文件的链接。 我试过下面的应用程序脚本代码。其他附件被下载到驱动器,但上面的链接没有被下载。请帮忙。
function saveAttachmentInFolder(){
const folderId = 'Drive id';
const searchQuery = 'Report download URL';
const threads = GmailApp.search(searchQuery, 0,25);
threads.forEach(thread => {
const messages = thread.getMessages();
messages.forEach(message => {
const attachments = message.getAttachments({
includeInlineImages: false,
includeAttachments: true
});
attachments.forEach(attachment => {
Drive.Files.insert(
{
title: attachment.getName(),
mimeType: attachment.getContentType(),
parents: [{ id: folderId }]
},
attachment.copyBlob()
);
});
});
});
};
【问题讨论】:
-
该文件是附加到电子邮件本身,还是仅包含一个下载文件的链接?
-
电子邮件包含下载文件的链接,文件未附加
标签: google-apps-script gmail-api