Outlook - Attachments
通过 Microsoft Graph API 下载和管理 Microsoft Outlook 邮件附件。
通过 Microsoft Graph 下载一封 Outlook 邮件的附件,按 MIME 类型和大小过滤,并以 base64 内容或编排器上的文件形式返回。
专为企业环境中大批量邮件处理设计的附件处理节点。支持按类型、大小过滤,对附件较多的邮件分页处理,并可将大文件以流式方式写入磁盘。
操作:
- List: 获取所有附件的元数据(名称、类型、大小),不下载内容。
- Download: 以 base64 形式下载附件内容,或直接写入临时文件。
- Download All: 下载某封邮件的全部附件,可选过滤。
工作原理
- 解析节点配置,必须提供
connection_id。获取 Graph 令牌:凭据密钥中包含client_id、client_secret、tenant_id时,以 client credentials 方式申请应用令牌;否则直接使用密钥中的token或access_token。 mailbox_mode为other时访问/users/<mailbox_email>,否则访问/me。message_source为custom时从custom_message_id获取邮件 ID,否则取输入项的id。- 列出邮件的全部附件,并跟随
@odata.nextLink分页。 - 保留
contentType以filter_content_type开头、且size位于filter_min_size与filter_max_size之间的附件。 - 过滤后没有附件时返回
no_attachments。否则返回success:每个附件附带content_bytes(base64);若为file模式,则将每个附件写入新的临时目录并返回其file_path。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-get-pdfs",
"label": "Get PDF attachments",
"operator_slug": "connectors.microsoft.outlook.attachments",
"operator_version": "1.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"mailbox_mode": "other",
"mailbox_email": "[email protected]",
"message_source": "incoming",
"filter_content_type": "application/pdf",
"filter_min_size": 1024,
"output_mode": "content"
}
}{
"ok": true,
"data": {
"attachments": [
{
"id": "AAMkAGI2THVSAAA=",
"name": "invoice-2026-0418.pdf",
"content_type": "application/pdf",
"size": 48213,
"content_bytes": "JVBERi0xLjcKJc...",
"is_inline": false
}
],
"count": 1
},
"port": "success"
}配置
-
connection_idstring 必填 -
用于访问 Microsoft Graph API 的凭据。接受 `oauth2`(access + refresh token)、`service-account`(tenant id + client id + client secret)或 `object`(高级 Graph 配置)类型的凭据。
-
mailbox_modestring 可选 -
mailbox_emailstring 可选 支持表达式 -
message_sourcestring 可选 -
Incoming:使用上一个节点传来的邮件 ID。Custom:手动指定消息 ID。
-
custom_message_idstring 可选 支持表达式 -
filter_content_typestring 可选 支持表达式 -
可选的 MIME 类型过滤(例如“application/pdf”“image/”)。支持前缀匹配。
-
filter_min_sizenumber 可选 -
附件最小大小(字节)。可用于过滤掉内嵌图片。
-
filter_max_sizenumber 可选 -
附件最大大小(字节)。
-
output_modestring 可选 -
Content:在载荷中返回 base64。File:写入 /tmp/ 并返回文件路径(大附件推荐使用)。
配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
mailbox_mode - 应用令牌(client credentials)没有
/me,此时请使用other并填写mailbox_email。 -
filter_content_type - 对
contentType进行区分大小写的前缀匹配(例如image/或application/pdf)。 -
output_mode file模式以附件名写入编排器的临时目录;同名附件会互相覆盖,节点不会清理这些文件。
输出端口
success 默认 至少有一个附件通过过滤。file 模式下每项包含 file_path 而不是 content_bytes。
{
"attachments": [
{
"id": "AAMkAGI2THVSAAA=",
"name": "invoice-2026-0418.pdf",
"content_type": "application/pdf",
"size": 48213,
"content_bytes": "JVBERi0xLjcKJc...",
"is_inline": false
}
],
"count": 1
}no_attachments 邮件没有附件,或没有附件通过过滤。
{
"attachments": [],
"count": 0
}error 校验失败(输出为信封 { ok, errors, port }),或 Graph 调用失败(输出为包含 Graph 错误体的 { error, response })。
{
"ok": false,
"errors": [
"Failed to resolve Microsoft 365 access token"
],
"port": "error"
}在表达式中
后续节点可通过 $("Outlook - Attachments").item.json.<路径> 读取此节点输出中的内容(请把 Outlook - Attachments 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 success 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Outlook - Attachments").item.json.attachments附件列表,包含元数据以及内容或路径。 | ||
$("Outlook - Attachments").item.json.count找到的附件数量。 |
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
Microsoft 365 credential is required | error | connection_id 为空。 |
Failed to resolve Microsoft 365 access token | error | 凭据无法解析、令牌申请失败,或密钥中既没有 client credentials 也没有令牌。具体原因不会返回。 |
Message ID is required. Ensure the previous node outputs an email with an ID, or select "Custom" and provide a Message ID. | error | 输入项中没有 id,也未设置自定义 ID。 |
Request failed with status code <status> | error | Graph 拒绝了调用:邮件 ID 或邮箱不存在时为 404,令牌过期或缺少 Mail.Read 权限时为 401/403。具体错误见 response。 |
输入契约
-
idstring 可选 -
来自触发器或上一个节点的消息 ID。
输出契约
-
attachmentsarray 可选 -
附件列表,包含元数据以及内容或路径。
-
countnumber 可选 -
找到的附件数量。
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "connectors.microsoft.outlook.attachments",
"name": "Outlook - Attachments",
"category": "integrations",
"version": "1.0.0",
"description": "Download and manage email attachments from Microsoft Outlook via Microsoft Graph API.\n\n Dedicated attachment handler for corporate environments with high-volume email processing. Supports filtering by type, size, pagination for emails with many attachments, and streaming to disk for large files.\n\n **Operations:**\n - **List:** Get metadata of all attachments (name, type, size) without downloading content.\n - **Download:** Download attachment content as base64 or write directly to temporary files.\n - **Download All:** Download all attachments from a message with optional filtering.",
"capabilities": [
"email",
"attachments",
"microsoft",
"outlook",
"office365"
],
"group": [
{
"key": "microsoft",
"name": "Microsoft",
"icon_url": "/icons/integrations/microsoft/microsoft.svg"
},
{
"key": "microsoft365",
"name": "Microsoft 365",
"icon_url": "/icons/integrations/microsoft/microsoft365.svg"
}
],
"icon_url": "/icons/integrations/microsoft/outlook.svg",
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "Microsoft 365 Credential",
"description": "Credential for Microsoft Graph API access. Accepts credentials of type `oauth2` (access + refresh token), `service-account` (tenant id + client id + client secret), or `object` (advanced Graph config).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"oauth2",
"service-account",
"object"
],
"types": [
"outlook",
"microsoft365",
"oauth2"
]
}
},
"mailbox_mode": {
"type": "string",
"title": "Mailbox",
"enum": [
"token_owner",
"other"
],
"default": "token_owner"
},
"mailbox_email": {
"type": "string",
"title": "Mailbox Email",
"format": "expression",
"displayOptions": {
"show": {
"mailbox_mode": [
"other"
]
}
}
},
"message_source": {
"type": "string",
"title": "Message Source",
"enum": [
"incoming",
"custom"
],
"default": "incoming",
"description": "Incoming: uses the email ID from the previous node. Custom: specify a message ID manually."
},
"custom_message_id": {
"type": "string",
"title": "Message ID",
"format": "expression",
"displayOptions": {
"show": {
"message_source": [
"custom"
]
}
}
},
"filter_content_type": {
"type": "string",
"title": "Filter by Type",
"description": "Optional MIME type filter (e.g., \"application/pdf\", \"image/\"). Supports prefix matching.",
"format": "expression"
},
"filter_min_size": {
"type": "number",
"title": "Min Size (bytes)",
"description": "Minimum attachment size in bytes. Useful for filtering out inline images."
},
"filter_max_size": {
"type": "number",
"title": "Max Size (bytes)",
"description": "Maximum attachment size in bytes."
},
"output_mode": {
"type": "string",
"title": "Output Mode",
"enum": [
"content",
"file"
],
"default": "content",
"description": "Content: returns base64 in payload. File: writes to /tmp/ and returns file paths (recommended for large attachments)."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"connection_id"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Message ID from the trigger or previous node."
}
}
},
"output_contract_schema": {
"type": "object",
"properties": {
"attachments": {
"type": "array",
"description": "List of attachments with metadata and content/path."
},
"count": {
"type": "number",
"description": "Number of attachments found."
}
}
},
"ports": [
{
"port_id": "success",
"label": "Attachments Found",
"is_default": true,
"supports_condition": true
},
{
"port_id": "no_attachments",
"label": "No Attachments",
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"supports_condition": false
}
],
"execution_mode": "async",
"tags": [
"email",
"attachments",
"microsoft",
"outlook",
"download"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "Microsoft 365 Credential",
"description": "Credential for Microsoft Graph API access. Accepts credentials of type `oauth2` (access + refresh token), `service-account` (tenant id + client id + client secret), or `object` (advanced Graph config).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"oauth2",
"service-account",
"object"
],
"types": [
"outlook",
"microsoft365",
"oauth2"
]
}
},
"mailbox_mode": {
"type": "string",
"title": "Mailbox",
"enum": [
"token_owner",
"other"
],
"default": "token_owner"
},
"mailbox_email": {
"type": "string",
"title": "Mailbox Email",
"format": "expression",
"displayOptions": {
"show": {
"mailbox_mode": [
"other"
]
}
}
},
"message_source": {
"type": "string",
"title": "Message Source",
"enum": [
"incoming",
"custom"
],
"default": "incoming",
"description": "Incoming: uses the email ID from the previous node. Custom: specify a message ID manually."
},
"custom_message_id": {
"type": "string",
"title": "Message ID",
"format": "expression",
"displayOptions": {
"show": {
"message_source": [
"custom"
]
}
}
},
"filter_content_type": {
"type": "string",
"title": "Filter by Type",
"description": "Optional MIME type filter (e.g., \"application/pdf\", \"image/\"). Supports prefix matching.",
"format": "expression"
},
"filter_min_size": {
"type": "number",
"title": "Min Size (bytes)",
"description": "Minimum attachment size in bytes. Useful for filtering out inline images."
},
"filter_max_size": {
"type": "number",
"title": "Max Size (bytes)",
"description": "Maximum attachment size in bytes."
},
"output_mode": {
"type": "string",
"title": "Output Mode",
"enum": [
"content",
"file"
],
"default": "content",
"description": "Content: returns base64 in payload. File: writes to /tmp/ and returns file paths (recommended for large attachments)."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"connection_id"
]
}{
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Message ID from the trigger or previous node."
}
}
}{
"type": "object",
"properties": {
"attachments": {
"type": "array",
"description": "List of attachments with metadata and content/path."
},
"count": {
"type": "number",
"description": "Number of attachments found."
}
}
}[
{
"port_id": "success",
"label": "Attachments Found",
"is_default": true,
"supports_condition": true
},
{
"port_id": "no_attachments",
"label": "No Attachments",
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 重试(
retryOnFail) - 否
- 凭据
- 在服务器端根据
connection_id解析,密钥不会进入工作流。 - 能力
emailattachmentsmicrosoftoutlookoffice365- 标签
emailattachmentsmicrosoftoutlookdownload
说明与限制
- 凭据中保存的 OAuth 访问令牌按原样使用,不会刷新;过期后 Graph 返回 401。
- 项目附件和引用附件不包含
contentBytes:content_bytes为null;在file模式下虽然会返回file_path,但不会写出文件。 content模式会将每个附件以 base64 放入工作流状态;大文件请优先使用file。节点不会重试。
已对照编排器代码核实 · 31e874b · 2026-11-26