> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/mail/read-outlook-oauth2.md).

# 读取Outlook（Oauth2）

读取 Outlook (OAuth2) 是一种专门的高级操作，用于从 Microsoft 生态系统（Outlook、Hotmail、Live 等）账户中读取验证码 (OTP)。与传统的 IMAP 方法不同，后者容易被 Microsoft 扫描阻止或要求身份验证，此操作使用 OAuth2 协议（通过刷新令牌和客户端 ID）。这是一个正式的连接机制，具有高安全性、极其稳定，并最大限度地减少在大规模运行时账户被检查点的情况。

#### 详细解释配置参数：

* Email|Pass|Refresh token|Client ID: 输入需要读取验证码的账户信息。目前，当您从提供 MMO 原料的网站购买 Outlook/Hotmail 账户时，通常会交付包含 4 个信息的格式结构，以竖线 `|` 分隔。您需要按照以下标准填写此框：`Email|Refresh token|Client ID.`
* Email sent to contains: 关键词或包含该短语的电子邮件地址，以便系统准确过滤所需查找的邮件。
  * *例如*: 如果您需要从 TikTok 发送的电子邮件中获取 OTP，地址为 `noreply@tiktok.com`，请准确填写 `noreply@tiktok.com`（或类似的短语如 `noreply@tiktok`）到此项中。
* 代理: 配置 IP 地址的选项，以便向 Microsoft 服务器发送连接请求，避免在批量检查邮件时 IP 重复。您可以设置：
  * *留空*: 使用当前计算机的原始网络。
  * *填写变量 `$profileProxy`*: 系统将自动选择当前 GPM 配置文件专用的代理。
  * *手动填写代理*: 直接输入指定的代理字符串，格式为 `ip:port` 或 `ip:port:user:pass`。
* 代码类型: 需要系统从邮件内容中提取的 OTP 代码的格式结构。包括 3 个选项：
  1. Number (数字类型): 当发送的 OTP 完全是连续数字时使用。
     * *代码长度*: 需要读取的 OTP 字符串的长度（例如，发送的代码为 `475997` ➔ 填写代码长度为 `6`）。
  2. Text (文本类型): 当 OTP 包含字母和数字，或隐藏在电子邮件的 HTML 标签结构中时使用。
     * *代码元素 xpath*: 直接指向包含需要提取的 OTP 的元素的 XPath 路径。
     * *代码元素属性*: 如果 OTP 是位于两个标签之间的内容，请填写 `text`（例如：`<h1>ABCDEF</h1>` ➔ 填写 `text`）。或者，如果 OTP 是标签属性中的值，请填写 *属性名称*（例如：`<h1 @code="ABCDEF"></h1>` ➔ 填写 `code`）。
  3. Full (整个电子邮件内容): 高级选项，帮助提取返回邮件的全部文本源代码或 HTML 代码，并赋值给输出变量。之后，您可以通过正则表达式或执行 JS 代码的操作，将此变量传递，以根据自己的需求编写灵活的提取规则。
* 输出变量: 用于存储 OTP 字符串（或根据 *代码类型* 配置的整个电子邮件内容）的输出变量名称，以便在脚本的后续输入操作中使用。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/mail/read-outlook-oauth2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
