在Google Drive文件夹中整理邮件附件
高级
这是一个File Management领域的自动化工作流,包含 17 个节点。主要使用 If, Set, Code, Gmail, Merge 等节点。 根据发件人邮箱在Google Drive文件夹中整理Gmail附件
前置要求
- •Google 账号和 Gmail API 凭证
- •Google Drive API 凭证
使用的节点 (17)
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "kAiLbJeChaiOyg6T",
"meta": {
"instanceId": "a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462",
"templateCredsSetupCompleted": true
},
"name": "在 Google Drive 文件夹中整理邮件附件",
"tags": [],
"nodes": [
{
"id": "f43882ce-f96b-4706-8428-6ff4d1689a88",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
112,
-656
],
"parameters": {
"filters": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "nyuHvSX5HuqfMPlW",
"name": "Gmail account (n3w.it)"
}
},
"typeVersion": 1.2
},
{
"id": "ff5b5a09-be36-45a3-b48d-3b24270117a9",
"name": "当点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
112,
-464
],
"parameters": {},
"typeVersion": 1
},
{
"id": "061aa9ae-cea6-4df3-b3cc-bc1f6b746c43",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
752,
-464
],
"parameters": {
"options": {
"reset": false
}
},
"typeVersion": 3
},
{
"id": "4f749dc4-e450-4150-9d97-0dd2ef450783",
"name": "拆分输出",
"type": "n8n-nodes-base.splitOut",
"position": [
1392,
-448
],
"parameters": {
"options": {},
"fieldToSplitOut": "$binary"
},
"typeVersion": 1
},
{
"id": "7a0281bf-1e45-4c00-acde-aa89f79ee578",
"name": "合并",
"type": "n8n-nodes-base.merge",
"position": [
2272,
-432
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineAll"
},
"typeVersion": 3.2
},
{
"id": "4827d788-9982-42f0-bf98-767ea5c890cc",
"name": "创建文件夹",
"type": "n8n-nodes-base.googleDrive",
"position": [
1792,
-16
],
"parameters": {
"name": "={{ $('Get email').item.json.from.value[0].address }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1EitwWVd5rKZTlvOreB4R-632zfEOyWzP",
"cachedResultUrl": "https://drive.google.com/drive/folders/1EitwWVd5rKZTlvOreB4R-632zfEOyWzP",
"cachedResultName": "Email Attachments"
},
"resource": "folder"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "HEy5EuZkgPZVEa9w",
"name": "Google Drive account (n3w.it)"
}
},
"typeVersion": 3
},
{
"id": "b77f08ca-70f3-4f4e-87dc-3c0cd365b3ee",
"name": "当由另一个工作流执行时",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
2656,
-656
],
"parameters": {
"inputSource": "passthrough"
},
"typeVersion": 1.1
},
{
"id": "4b81e6cb-784b-4cef-a65f-5b3664e52db5",
"name": "执行工作流",
"type": "n8n-nodes-base.executeWorkflow",
"position": [
2640,
-432
],
"parameters": {
"mode": "each",
"options": {
"waitForSubWorkflow": true
},
"workflowId": {
"__rl": true,
"mode": "id",
"value": "kAiLbJeChaiOyg6T"
},
"workflowInputs": {
"value": {},
"schema": [],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": true
}
},
"typeVersion": 1.2
},
{
"id": "d50b2f82-1120-4496-ad33-7196b8996723",
"name": "获取邮件",
"type": "n8n-nodes-base.gmail",
"position": [
416,
-464
],
"webhookId": "2e7b7f4e-338b-4145-9657-768251c2193b",
"parameters": {
"simple": false,
"filters": {
"receivedAfter": "2025-07-06T00:00:00",
"receivedBefore": "2025-07-09T23:00:00"
},
"options": {
"downloadAttachments": true
},
"operation": "getAll"
},
"credentials": {
"gmailOAuth2": {
"id": "nyuHvSX5HuqfMPlW",
"name": "Gmail account (n3w.it)"
}
},
"typeVersion": 2.1
},
{
"id": "c030f11a-dc3d-4e20-8ad2-46afafb9cbdb",
"name": "获取邮件",
"type": "n8n-nodes-base.gmail",
"position": [
1104,
-448
],
"webhookId": "a799e546-0244-4d2d-b0d1-e6bd5fea7938",
"parameters": {
"simple": false,
"options": {
"downloadAttachments": true
},
"messageId": "={{ $json.id }}",
"operation": "get"
},
"credentials": {
"gmailOAuth2": {
"id": "nyuHvSX5HuqfMPlW",
"name": "Gmail account (n3w.it)"
}
},
"typeVersion": 2.1
},
{
"id": "53ca4e5b-5840-473a-8343-1ea07f4ea9b0",
"name": "包含附件?",
"type": "n8n-nodes-base.if",
"position": [
1104,
-160
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "fb9c769f-1a9d-44a5-a655-bee8f53e573e",
"operator": {
"type": "object",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $binary }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "11f81936-1b0a-4dc8-b4a2-910c6b7622be",
"name": "搜索文件夹",
"type": "n8n-nodes-base.googleDrive",
"position": [
1360,
-176
],
"parameters": {
"limit": 1,
"filter": {
"folderId": {
"__rl": true,
"mode": "list",
"value": "1EitwWVd5rKZTlvOreB4R-632zfEOyWzP",
"cachedResultUrl": "https://drive.google.com/drive/folders/1EitwWVd5rKZTlvOreB4R-632zfEOyWzP",
"cachedResultName": "Email Attachments"
},
"whatToSearch": "folders"
},
"options": {},
"resource": "fileFolder",
"queryString": "={{ $('Get email').item.json.from.value[0].address }}"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "HEy5EuZkgPZVEa9w",
"name": "Google Drive account (n3w.it)"
}
},
"typeVersion": 3,
"alwaysOutputData": true
},
{
"id": "89d037ce-e0ae-4199-9cf7-d3bd4aa4bf8d",
"name": "存在?",
"type": "n8n-nodes-base.if",
"position": [
1616,
-176
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "f6b34be9-edeb-4ebc-bd18-bccf43c7b7db",
"operator": {
"type": "object",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "b2475306-50e8-434a-9ef0-efdb9afeb08e",
"name": "文件夹ID",
"type": "n8n-nodes-base.set",
"position": [
1984,
-192
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "f148d473-dde0-444e-8060-1b8608b18d13",
"name": "folder_id",
"type": "string",
"value": "={{ $json.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "97c82abe-87ac-4b72-bb00-1616b8ca4731",
"name": "获取附件",
"type": "n8n-nodes-base.code",
"position": [
1824,
-448
],
"parameters": {
"jsCode": "let results = [];\n\nfor (item of items) {\n for (key of Object.keys(item.binary)) {\n results.push({\n json: {\n fileName: item.binary[key].fileName\n },\n binary: {\n data: item.binary[key],\n }\n });\n }\n}\n\nreturn results;"
},
"typeVersion": 2
},
{
"id": "3fa07a7b-505b-474b-9dba-2c8cd0bc02cc",
"name": "上传附件",
"type": "n8n-nodes-base.googleDrive",
"position": [
2928,
-656
],
"parameters": {
"name": "={{ $data.fileName }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.folder_id }}"
},
"inputDataFieldName": "=data"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "HEy5EuZkgPZVEa9w",
"name": "Google Drive account (n3w.it)"
}
},
"typeVersion": 3
},
{
"id": "772dd36f-ef1a-48bf-89e5-feba92b963c2",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
112,
-912
],
"parameters": {
"width": 704,
"height": 208,
"content": "## 基于发件人邮箱在 Google Drive 文件夹中整理 Gmail 附件"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "9e6eac7d-2e84-476a-a93b-63471017778c",
"connections": {
"Merge": {
"main": [
[
{
"node": "Execute Workflow",
"type": "main",
"index": 0
}
]
]
},
"Exist?": {
"main": [
[
{
"node": "Folder ID",
"type": "main",
"index": 0
}
],
[
{
"node": "Create folder",
"type": "main",
"index": 0
}
]
]
},
"Folder ID": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Get email": {
"main": [
[
{
"node": "Contain attachments?",
"type": "main",
"index": 0
},
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Get attachments",
"type": "main",
"index": 0
}
]
]
},
"Get emails": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Create folder": {
"main": [
[
{
"node": "Folder ID",
"type": "main",
"index": 0
}
]
]
},
"Search folders": {
"main": [
[
{
"node": "Exist?",
"type": "main",
"index": 0
}
]
]
},
"Get attachments": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Get email",
"type": "main",
"index": 0
}
]
]
},
"Execute Workflow": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Upload attachment": {
"main": [
[]
]
},
"Contain attachments?": {
"main": [
[
{
"node": "Search folders",
"type": "main",
"index": 0
}
],
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Upload attachment",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Get emails",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 文件管理
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
自动翻译Google Slides演示文稿
基于Gemini的AI驱动自动翻译Google Slides演示文稿至任意语言
Set
Code
Wait
+12
18 节点Davide
文档提取
(Duc)深度研究市场模板
集成PerplexityAI研究和OpenAI内容的多层级WordPress博客生成器
If
Set
Xml
+28
132 节点Daniel Ng
人工智能
基于 Mistral OCR 的完整 RAG 从 PDF 开始
使用Mistral OCR、Qdrant和Gemini AI构建PDF文档RAG系统
Set
Code
Wait
+16
34 节点Davide
人工智能
我的智能体竞技场社区竞赛
使用Qdrant、Mistral OCR和GPT-4构建基于RAG的问答系统
Set
Code
Wait
+19
41 节点Davide
内容创作
基于AI的MIS代理
基于AI的管理信息系统代理
If
Set
Code
+29
129 节点Kumar Shivam
客户支持
工作流信息
难度等级
高级
节点数量17
分类1
节点类型13
作者
Davide
@n3witaliaFull-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at info@n3w.it or add me on Linkedin.com/in/davideboizza
外部链接
在 n8n.io 查看 →
分享此工作流