本页内容
Sommatic 文档
打开控制台

Outlook - Mail

通过 Microsoft Graph API 在 Microsoft Outlook 中发送、读取和管理邮件。

以 Markdown 查看
在以下应用中打开
连接器 可用 connectors.microsoft.outlook.mail 版本 1.0.0 执行方式: async

通过 Microsoft Graph 发送、回复、转发、读取、列出或删除 Outlook 邮件,或读取邮件附件。所选操作的结果放在 result 中返回。

连接你的 Microsoft 365 账户,自动化邮件操作:发送通知、处理收到的邮件、管理草稿等。

操作:

  • Send: 撰写并发送新邮件,包含收件人、主题、正文和可选附件。
  • Reply: 按消息 ID 回复现有邮件。
  • Get: 按消息 ID 获取特定邮件。
  • List: 列出某个文件夹中的邮件,可选过滤。
  • Delete: 按消息 ID 删除邮件。
  • Forward: 将邮件转发给新的收件人。

工作原理

  1. 解析节点配置,必须提供 connection_id。获取 Graph 令牌:凭据密钥中包含 client_id、client_secret、tenant_id 时申请应用令牌;否则直接使用密钥中的 token 或 access_token。
  2. mailbox_mode 为 other 时访问 /users/<mailbox_email>,否则访问 /me,并按 operation(默认 send)分派。
  3. send 必须提供 to 和 subject,按逗号拆分 to、cc、bcc,并以 HTML 或纯文本正文(content_type)调用 sendMail。
  4. reply 在 reply_target 为 custom 时使用 custom_message_id,否则依次使用输入项的 id 和 message_id。无覆盖项时以 body 作为评论调用 /reply。设置了 to、cc、bcc 或 include_quoted_original: false 时,会创建回复草稿,设置收件人和正文(你的内容 + <hr/> + 引用的原文,除非关闭引用),然后发送。
  5. forward 必须提供 message_id 和 to。无覆盖项时调用 /forward。设置了 forward_subject、forward_importance、timezone、language、cc 或 bcc 时,会创建转发草稿(为引用头发送 Prefer: outlook.timezone 和 Accept-Language),修改后发送,并返回其 conversation_id 和 internet_message_id(取自草稿,或在“已发送邮件”中最多查找 5 次,每次间隔 1.5 秒)。
  6. get 返回 message_id 对应的 Graph 邮件;list 按时间倒序返回 folder 中最多 limit 封邮件,可用 OData filter 过滤;delete 删除 message_id;get_attachments 返回输入项 id(或 message_id)对应邮件的附件。

在工作流中

节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。

{
  "node_id": "node-confirm-order",
  "label": "Send confirmation",
  "operator_slug": "connectors.microsoft.outlook.mail",
  "operator_version": "1.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "mailbox_mode": "other",
    "mailbox_email": "orders@example.com",
    "operation": "send",
    "to": "{{ $json.customer_email }}",
    "subject": "Order {{ $json.order_id }} received",
    "body": "<p>Thanks, we received your order.</p>",
    "content_type": "html"
  }
}

配置

connection_id string 必填

用于访问 Microsoft Graph API 的凭据。接受 `oauth2`(access + refresh token)、`service-account`(tenant id + client id + client secret)或 `object`(高级 Graph 配置)类型的凭据。

mailbox_mode string 可选

Token owner:使用生成该凭据的账户的邮箱。Other mailbox:指定一个邮箱地址(需要在 Azure AD 中授予 Application 权限)。

默认值: token_owner

可选值: token_ownerother

mailbox_email string 可选 支持表达式

要操作的邮箱地址(例如 support@organization.com)。

显示条件: mailbox_mode = other

operation string 必填

要执行的邮件操作。

默认值: send

可选值: sendreplygetlistdeleteforwardget_attachments

to string 可选 支持表达式

以逗号分隔的邮箱,用于覆盖默认的回复收件人(Graph 默认设为原发件人)。可将回复发往例如法院邮箱,而不是转发该案件的自然人。会触发增强的 4 次调用流程。

显示条件: operation = reply

cc string 可选 支持表达式

以逗号分隔的邮箱,接收回复的可见抄送。

显示条件: operation = reply

bcc string 可选 支持表达式

以逗号分隔的邮箱,接收回复的密送。会触发增强的 4 次调用流程(createReply → PATCH → send),并保留原邮件引用。

显示条件: operation = reply

subject string 可选 支持表达式

邮件主题。

显示条件: operation = send

body string 可选 支持表达式

邮件正文内容。支持 HTML。

显示条件: operation = send | reply

content_type string 可选

正文为纯文本还是 HTML。

默认值: html

可选值: texthtml

显示条件: operation = send | reply

reply_target string 可选

Incoming message:自动回复从上一个节点收到的邮件。Custom:手动指定消息 ID。

默认值: incoming

可选值: incomingcustom

显示条件: operation = reply

custom_message_id string 可选 支持表达式

要回复的邮件 ID。

显示条件: operation = reply · reply_target = custom

message_id string 可选 支持表达式

邮件消息的 ID。

显示条件: operation = get | delete | forward

forward_subject string 可选 支持表达式

转发邮件的自定义主题。留空时,Outlook 会在原主题前加上“FW: ”(Graph 默认行为)。

显示条件: operation = forward

forward_importance string 可选

转发邮件的重要性标记。设为“high”可标记为紧急。留空 = 默认(normal)。

可选值: lownormalhigh

显示条件: operation = forward

timezone string 可选

可选的 Windows 时区名称,用于转发邮件引用头中显示的时间(例如哥伦比亚使用“SA Pacific Standard Time”)。留空 = UTC(Graph 默认行为)。

显示条件: operation = forward

language string 可选

可选的语言标签,用于转发邮件引用头中的标签文字(例如“es-CO”显示 De / Enviado / Para / Asunto)。留空 = 英语(Graph 默认行为)。星期和月份名称仍为英文。

显示条件: operation = forward

folder string 可选

要列出邮件的邮件文件夹。

默认值: inbox

可选值: inboxsentitemsdraftsdeleteditemsjunkemailarchive

显示条件: operation = list

limit number 可选

返回的最大邮件数。

默认值: 10

显示条件: operation = list

filter string 可选 支持表达式

OData 过滤表达式(例如“isRead eq false”)。

显示条件: operation = list

配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。

代码中的行为

除 schema 描述之外,实现代码对这些键的实际处理。

to
to、cc、bcc 在定义中被声明了两次,后一次(回复覆盖项)生效,因此表单只在 reply 时显示它们。但 worker 在 send 和 forward 中仍会读取 to、cc、bcc。
include_quoted_original 代码会读取,但未声明
未声明,默认 true。设为 false 时 reply 只以 HTML 发送 body,不包含 Graph 引用的原文。
content_type
仅 send 使用。回复和转发沿用 Graph 草稿的内容类型。
attachment_filter 代码会读取,但未声明
未声明(别名 filter_content_type)。用于 get_attachments,保留内容类型以该值开头的附件,不区分大小写。
timezone
仅用于转发:引用头中时间所用的 Windows 时区名称。language(如 es-ES 的语言标签)设置其标签文字。设置任一项都会改用基于草稿的转发。

输出端口

out 默认

操作成功。输出为 { result, operation };get_attachments 除外,它返回 { attachments, count },恰好一个附件时还会附带 attachment。

数据
{
  "result": {
    "sent": true,
    "status": 202
  },
  "operation": "send"
}
error

校验失败(输出为信封 { ok, errors, port }),或 Graph 调用失败(输出为包含 Graph 错误体的 { error, response })。

数据
{
  "ok": false,
  "errors": [
    "Recipient (to) is required for send operation"
  ],
  "port": "error"
}

在表达式中

后续节点可通过 $("Outlook - Mail").item.json.<路径> 读取此节点输出中的内容(请把 Outlook - Mail 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。

表达式EditorWorker
$("Outlook - Mail").item.json.resultobject= {…}Microsoft Graph API 返回的操作结果。
$("Outlook - Mail").item.json.operationstring= "send"所执行的操作。
$("Outlook - Mail").item.json.result.sentboolean编辑器不提示= true—
$("Outlook - Mail").item.json.result.statusnumber编辑器不提示= 202—

— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。

错误

消息 端口 原因与处理
Microsoft 365 credential is required error connection_id 为空。
Failed to resolve Microsoft 365 access token error 凭据无法解析、令牌申请失败,或密钥中既没有 client credentials 也没有令牌。
Unknown operation: <operation> error operation 不是 send、reply、get、list、delete、forward 或 get_attachments。
Recipient (to) is required for <send|forward> operation error to 为空。Subject is required for send operation 是对 subject 的同类校验。
Message ID is required for <get|delete|forward> operation error message_id 为空。reply 和 get_attachments 会返回提及上一节点的较长提示。
createReply did not return a draft message id error Graph 未创建回复草稿。createForward did not return a draft message id 是转发时的对应错误。
Request failed with status code <status> error Graph 拒绝了调用(邮件不存在、OData 过滤条件无效、缺少 Mail.Send / Mail.ReadWrite 权限、令牌过期等)。具体错误见 response。

输入契约

connection_id string 必填
operation string 必填
to string 可选
subject string 可选
body string 可选
message_id string 可选

输出契约

result object 可选

Microsoft Graph API 返回的操作结果。

operation string 可选

所执行的操作。

契约(JSON Schema)

与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。

{
  "slug": "connectors.microsoft.outlook.mail",
  "name": "Outlook - Mail",
  "category": "integrations",
  "version": "1.0.0",
  "description": "Send, read, and manage emails through Microsoft Outlook via the Microsoft Graph API.\n\n  Connect your Microsoft 365 account and automate email operations — send notifications, process incoming mail, manage drafts, and more.\n\n  **Operations:**\n  - **Send:** Compose and send a new email with recipients, subject, body, and optional attachments.\n  - **Reply:** Reply to an existing email by message ID.\n  - **Get:** Retrieve a specific email by message ID.\n  - **List:** List emails from a folder with optional filtering.\n  - **Delete:** Delete an email by message ID.\n  - **Forward:** Forward an email to new recipients.",
  "capabilities": [
    "email",
    "microsoft",
    "outlook",
    "office365",
    "graph-api"
  ],
  "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",
        "description": "Token owner: uses the mailbox of the account that generated the credential. Other mailbox: specify an email address (requires Application permissions in Azure AD)."
      },
      "mailbox_email": {
        "type": "string",
        "title": "Mailbox Email",
        "description": "Email address of the mailbox to operate on (e.g., support@organization.com).",
        "format": "expression",
        "displayOptions": {
          "show": {
            "mailbox_mode": [
              "other"
            ]
          }
        }
      },
      "operation": {
        "type": "string",
        "title": "Operation",
        "enum": [
          "send",
          "reply",
          "get",
          "list",
          "delete",
          "forward",
          "get_attachments"
        ],
        "default": "send",
        "description": "The email operation to perform."
      },
      "to": {
        "type": "string",
        "title": "To (Reply override)",
        "description": "Comma-separated emails to override the default reply recipient (which Graph sets to the original sender). Use to route the reply to e.g. the court mailbox instead of the natural-person who forwarded the case. Triggers enriched 4-call flow.",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "reply"
            ]
          }
        }
      },
      "cc": {
        "type": "string",
        "title": "CC (Reply)",
        "description": "Comma-separated emails to receive a visible copy of the reply.",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "reply"
            ]
          }
        }
      },
      "bcc": {
        "type": "string",
        "title": "BCC (Reply)",
        "description": "Comma-separated emails to receive a blind copy of the reply. Triggers enriched 4-call flow (createReply → PATCH → send) and preserves the original message quote.",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "reply"
            ]
          }
        }
      },
      "subject": {
        "type": "string",
        "title": "Subject",
        "description": "Email subject line.",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "send"
            ]
          }
        }
      },
      "body": {
        "type": "string",
        "title": "Body",
        "description": "Email body content. Supports HTML.",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "send",
              "reply"
            ]
          }
        }
      },
      "content_type": {
        "type": "string",
        "title": "Content Type",
        "enum": [
          "text",
          "html"
        ],
        "default": "html",
        "description": "Whether the body is plain text or HTML.",
        "displayOptions": {
          "show": {
            "operation": [
              "send",
              "reply"
            ]
          }
        }
      },
      "reply_target": {
        "type": "string",
        "title": "Reply To",
        "enum": [
          "incoming",
          "custom"
        ],
        "default": "incoming",
        "description": "Incoming message: automatically replies to the email received from the previous node. Custom: specify a message ID manually.",
        "displayOptions": {
          "show": {
            "operation": [
              "reply"
            ]
          }
        }
      },
      "custom_message_id": {
        "type": "string",
        "title": "Message ID",
        "description": "The ID of the email to reply to.",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "reply"
            ],
            "reply_target": [
              "custom"
            ]
          }
        }
      },
      "message_id": {
        "type": "string",
        "title": "Message ID",
        "description": "The ID of the email message.",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "get",
              "delete",
              "forward"
            ]
          }
        }
      },
      "forward_subject": {
        "type": "string",
        "title": "Forward Subject (override)",
        "description": "Custom subject for the forwarded message. If empty, Outlook prefixes \"FW: \" to the original subject (default Graph behavior).",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "forward"
            ]
          }
        }
      },
      "forward_importance": {
        "type": "string",
        "title": "Forward Importance",
        "enum": [
          "",
          "low",
          "normal",
          "high"
        ],
        "default": "",
        "description": "Importance flag for the forwarded message. Set to \"high\" to mark as urgent. Empty = default (normal).",
        "displayOptions": {
          "show": {
            "operation": [
              "forward"
            ]
          }
        }
      },
      "timezone": {
        "type": "string",
        "title": "Forward Time Zone",
        "description": "Optional Windows time zone name used for the time shown in the quoted header of the forwarded message (e.g. \"SA Pacific Standard Time\" for Colombia). Empty = UTC (default Graph behavior).",
        "default": "",
        "displayOptions": {
          "show": {
            "operation": [
              "forward"
            ]
          }
        }
      },
      "language": {
        "type": "string",
        "title": "Forward Language",
        "description": "Optional language tag for the labels of the quoted header of the forwarded message (e.g. \"es-CO\" shows De / Enviado / Para / Asunto). Empty = English (default Graph behavior). Day and month names stay in English.",
        "default": "",
        "displayOptions": {
          "show": {
            "operation": [
              "forward"
            ]
          }
        }
      },
      "folder": {
        "type": "string",
        "title": "Folder",
        "enum": [
          "inbox",
          "sentitems",
          "drafts",
          "deleteditems",
          "junkemail",
          "archive"
        ],
        "default": "inbox",
        "description": "The mail folder to list messages from.",
        "displayOptions": {
          "show": {
            "operation": [
              "list"
            ]
          }
        }
      },
      "limit": {
        "type": "number",
        "title": "Limit",
        "default": 10,
        "description": "Maximum number of messages to return.",
        "displayOptions": {
          "show": {
            "operation": [
              "list"
            ]
          }
        }
      },
      "filter": {
        "type": "string",
        "title": "Filter",
        "description": "OData filter expression (e.g., \"isRead eq false\").",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "list"
            ]
          }
        }
      },
      "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",
      "operation"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string"
      },
      "operation": {
        "type": "string"
      },
      "to": {
        "type": "string"
      },
      "subject": {
        "type": "string"
      },
      "body": {
        "type": "string"
      },
      "message_id": {
        "type": "string"
      }
    },
    "required": [
      "connection_id",
      "operation"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": "object",
        "description": "Operation result from Microsoft Graph API."
      },
      "operation": {
        "type": "string",
        "description": "The operation that was performed."
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Success",
      "description": "Operation completed successfully.",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Operation failed (auth error, invalid message ID, API error).",
      "is_default": false,
      "supports_condition": true
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "standard-io",
    "cloud-io"
  ],
  "tags": [
    "email",
    "microsoft",
    "outlook",
    "office365",
    "send",
    "connector"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

执行

执行方式
async
有状态
否
重试(retryOnFail)
否
凭据
在服务器端根据 connection_id 解析,密钥不会进入工作流。
能力
emailmicrosoftoutlookoffice365graph-api
标签
emailmicrosoftoutlookoffice365sendconnector

说明与限制

  • list 和 get_attachments 只读取一页 Graph 结果;get_attachments 会包含每个附件的 base64 contentBytes。
  • 发送类操作不是幂等的,节点不会重试;重新运行失败的工作流可能导致邮件发送两次。
  • 凭据中保存的 OAuth 访问令牌不会刷新。应用令牌没有 /me,需要使用 mailbox_mode: other。
  • 基于草稿的回复和转发会返回 draft_id、conversation_id 和 internet_message_id,可供 connectors.microsoft.outlook.message.category 为已发送副本打标签。

已对照编排器代码核实 · 31e874b · 2026-11-26

安装智能体工具

为你的编程智能体接入 Sommatic AI 官方文档:技能包、文档 MCP 服务器与 Markdown 页面,无需再抓取网页。

安装 Sommatic AI CLI,并为检测到的智能体配置合适的插件。

npx @sommatic/cli agent setup
智能体如何读取本文档