8
n8n 中文网amn8n.com

邮件到文件夹

中级

这是一个IT Ops领域的自动化工作流,包含 8 个节点。主要使用 Gmail, Merge, Filter, SplitOut, GoogleDrive 等节点。 将Gmail邮件附件整理到结构化的Google Drive文件夹

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Drive API 凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "9rIwaQlNKOLLs6Yi",
  "meta": {
    "instanceId": "6304e8877aa0fde3913b14034debe07006963fb497d63f280a91bbd75c6c24e1",
    "templateCredsSetupCompleted": true
  },
  "name": "邮件到文件夹",
  "tags": [],
  "nodes": [
    {
      "id": "f0c308d6-9347-441b-a78b-b25de884f942",
      "name": "Gmail 触发器",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -340,
        220
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {
          "downloadAttachments": true
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "B0oVer8pX52LHrvw",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "54a70814-0185-420b-a7e7-66ed811fae3c",
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1040,
        220
      ],
      "parameters": {
        "name": "={{ $json.id }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $node[\"Create Folder\"].json.id }}"
        },
        "inputDataFieldName": "={{ $binary.keys()[0] }}"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "0Fpa71OWKyUgnl7d",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "435c21d8-7d23-447d-a081-a4991ba42a41",
      "name": "创建文件夹",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        380,
        160
      ],
      "parameters": {
        "name": "=Motion - {{ $node[\"Gmail Trigger\"].json.subject || \"Untitled\" }} - {{ $now }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        },
        "resource": "folder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "0Fpa71OWKyUgnl7d",
          "name": "Google Drive account"
        }
      },
      "executeOnce": true,
      "typeVersion": 3
    },
    {
      "id": "3acb5376-3528-4a30-9612-67bd1a509adc",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -20
      ],
      "parameters": {
        "color": 6,
        "width": 1700,
        "height": 660,
        "content": "从邮件中获取 PDF 并创建带 PDF 的新文件夹"
      },
      "typeVersion": 1
    },
    {
      "id": "e4aef0db-b072-4dc7-80e0-cd3658555bda",
      "name": "过滤器",
      "type": "n8n-nodes-base.filter",
      "position": [
        -120,
        220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "87e927b3-4f28-4843-b2d0-cf7269437fca",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('Gmail Trigger').item.binary}}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4218230f-ccd0-4b8b-a4b3-54749ce8a738",
      "name": "Gmail1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        100,
        220
      ],
      "webhookId": "e25bd1d4-d39f-4620-a5db-d6d3d9db6843",
      "parameters": {
        "simple": false,
        "options": {
          "downloadAttachments": true
        },
        "messageId": "={{ $node[\"Gmail Trigger\"].json.id }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "B0oVer8pX52LHrvw",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "833ab358-ce62-4acf-847e-0251bfb8e123",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        700,
        220
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.1
    },
    {
      "id": "55de30ff-40de-4b51-b5bd-0c00fbba80be",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        380,
        360
      ],
      "parameters": {
        "options": {
          "includeBinary": true
        },
        "fieldToSplitOut": "$binary"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5d7c63e5-67f2-483d-8ebe-0c90967a1137",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Gmail1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail1": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Create Folder": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive1": {
      "main": [
        []
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量8
分类1
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Michael Gullo

Michael Gullo

@drdoom

I’m passionate about using n8n to create realistic workflows that help working class people simplify their daily tasks. My workflows aim to make life easier by eliminating mundane, repetitive responsibilities that take up valuable time. I love turning automation into a tool that lets people focus on what matters most to them.

外部链接
在 n8n.io 查看

分享此工作流