8
n8n 中文网amn8n.com

清理我的邮件

中级

这是一个IT Ops领域的自动化工作流,包含 12 个节点。主要使用 Gmail, Merge, SplitOut, ScheduleTrigger 等节点。 自动删除 Gmail 中的垃圾邮件、社交邮件和推广邮件

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

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "dI8MDIAVRPRIMA9K",
  "meta": {
    "instanceId": "c2650793f644091dc80fb900fe63448ad1f4b774008de9608064d67294f8307c",
    "templateCredsSetupCompleted": true
  },
  "name": "清理我的邮件",
  "tags": [],
  "nodes": [
    {
      "id": "8a921410-15a0-4b0e-9104-19ffa1dd51d0",
      "name": "删除所有邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        320,
        500
      ],
      "webhookId": "b1e6a886-f0ae-479a-a25c-37a6bd9b6c65",
      "parameters": {
        "messageId": "={{ $json.id }}",
        "operation": "delete"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "8p11S7abjY8KddB9",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0b0fe192-6ead-4011-b469-79da8f8033ff",
      "name": "调整设置",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -740,
        120
      ],
      "parameters": {
        "width": 500,
        "height": 740,
        "content": "## 📧 Gmail 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "b4e2ca40-3850-478f-b78d-b6814353a68a",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1220,
        360
      ],
      "parameters": {
        "width": 360,
        "height": 240,
        "content": "## ⏰ 计划触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "25bb2611-3188-478b-ac6d-23ed621b4d50",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -180,
        360
      ],
      "parameters": {
        "width": 420,
        "height": 240,
        "content": "## 🔀 合并和准备 ID"
      },
      "typeVersion": 1
    },
    {
      "id": "1393ff41-bafd-437c-877f-be9e62c109c0",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        360
      ],
      "parameters": {
        "width": 420,
        "height": 240,
        "content": "## 🗑️ 删除邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "cbbbaf18-29e4-4a97-8614-3dfeeced42a7",
      "name": "每 3 天运行(触发器)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -960,
        500
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "daysInterval": 3
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ecc3647d-f81c-4605-8f66-2a47d20b7dde",
      "name": "获取垃圾邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -540,
        320
      ],
      "webhookId": "ab59faf5-0db2-4bd3-ac09-e59b5ef77a11",
      "parameters": {
        "filters": {
          "labelIds": [
            "SPAM"
          ]
        },
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "8p11S7abjY8KddB9",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1,
      "alwaysOutputData": true
    },
    {
      "id": "4a288d12-0fb4-44aa-9c41-242cae4f5dd6",
      "name": "获取社交邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -540,
        500
      ],
      "webhookId": "1ad90798-b252-4856-af51-744b645e2725",
      "parameters": {
        "filters": {
          "labelIds": [
            "CATEGORY_SOCIAL"
          ]
        },
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "8p11S7abjY8KddB9",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1,
      "alwaysOutputData": true
    },
    {
      "id": "f65f55af-3374-42fd-98fe-2cfd543077a5",
      "name": "获取推广邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -540,
        680
      ],
      "webhookId": "0f24dcf5-dc5e-4395-a9ec-d0c17dbfeac0",
      "parameters": {
        "filters": {
          "labelIds": [
            "CATEGORY_PROMOTIONS"
          ]
        },
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "8p11S7abjY8KddB9",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1,
      "alwaysOutputData": true
    },
    {
      "id": "5b1f0245-960c-4c38-a3c9-8545f7838836",
      "name": "合并所有获取的邮件",
      "type": "n8n-nodes-base.merge",
      "position": [
        -160,
        500
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.1
    },
    {
      "id": "f97101f1-592e-4295-b3f1-a632a5a15551",
      "name": "拆分邮件 ID(每项一个)",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        40,
        500
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "id"
      },
      "typeVersion": 1
    },
    {
      "id": "8d354e0a-0d21-4446-8b58-3d86eb5fbc8d",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -180,
        700
      ],
      "parameters": {
        "color": 7,
        "width": 420,
        "height": 240,
        "content": "## ☕ 嘿,这个工具完全免费!"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "34278343-eec2-4602-90f8-60d4cfa3bc3f",
  "connections": {
    "Delete All Mails": {
      "main": [
        []
      ]
    },
    "Fetch SPAM Emails": {
      "main": [
        [
          {
            "node": "Combine All Fetched Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Social Emails": {
      "main": [
        [
          {
            "node": "Combine All Fetched Emails",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Fetch Promotion Emails": {
      "main": [
        [
          {
            "node": "Combine All Fetched Emails",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Combine All Fetched Emails": {
      "main": [
        [
          {
            "node": "Split Email IDs (One per item)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Every 3 Days (Trigger)": {
      "main": [
        [
          {
            "node": "Fetch SPAM Emails",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Social Emails",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Promotion Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Email IDs (One per item)": {
      "main": [
        [
          {
            "node": "Delete All Mails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - IT 运维

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流