Duaer

应用配方

在 Duaer 里把 Gmail 附件自动存到 Google Drive

在 Duaer 里,带附件的新邮件一到,就把每个附件按原文件名上传到 Google Drive 的指定文件夹。

在 Duaer 里搭附件归档

  1. 加 Gmail Trigger,关掉 Simplify,在 Options 里打开 Download Attachments;Filters 的 Search 写 has:attachment。
  2. 附件会放在 attachment_0、attachment_1 …… 上。接 Code,粘贴下面的代码,一个附件一条,文件都放在 data 上。
  3. 只要 PDF 时接 If,条件 {{ $json.fileName.toLowerCase().endsWith('.pdf') }} 为 true。
  4. 接 Google Drive,Resource 选 File,Operation 选 Upload,Input Data Field Name 填 data,File Name 填 {{ $json.fileName }},选 Parent Drive 和 Parent Folder。
  5. 发布数字组织。
const out = [];
for (const item of $input.all()) {
  for (const key of Object.keys(item.binary ?? {})) {
    out.push({
      json: { ...item.json, fileName: item.binary[key].fileName },
      binary: { data: item.binary[key] },
    });
  }
}
return out;

按发件人或月份分文件夹

File Name 可以带上日期,例如 {{ $now.toFormat('yyyy-MM') }}-{{ $json.fileName }}。要真正分文件夹,先用 Google Drive 的 Folder 创建操作建好,再把 Parent Folder 改成表达式。

常见问题

Duaer 会重复保存同一封邮件的附件吗?

不会。Duaer 的 Gmail Trigger 每封新邮件只触发一次;手动重跑旧执行时才会再传一遍。

Duaer 能存企业邮箱或 QQ 邮箱的附件吗?

能。把 Gmail Trigger 换成 Email Trigger (IMAP),打开下载附件,后面的 Duaer 步骤不变。

同组