> 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-en/action-guides/mail/read-outlook-oauth2.md).

# Read outlook (Oauth2)

Read outlook (OAuth2) is a specialized advanced action used to read the authentication code (OTP) from accounts within the Microsoft ecosystem (Outlook, Hotmail, Live...). Unlike the traditional IMAP method, which is easily blocked or requires identity verification by Microsoft, this action uses the OAuth2 protocol (via Refresh Token and Client ID). This is an official connection mechanism, highly secure, extremely stable, and minimizes the risk of account checkpoint when running in large quantities (mass).

#### Detailed explanation of configuration parameters:

* Email|Pass|Refresh token|Client ID: Input field for the account information needed to read the authentication code. Currently, when purchasing Outlook/Hotmail accounts from websites providing MMO resources, you are often given a format structure consisting of 4 pieces of information separated by the vertical bar `|`. You need to fill in this field according to the following standard: `Email|Refresh token|Client ID.`
* Email sent to contains: A keyword or email address that contains that phrase for the system to accurately filter the email needed.
  * *For example*: If you need to retrieve the OTP from an email sent by TikTok with the address `noreply@tiktok.com`, please enter exactly `noreply@tiktok.com` (or a distinguishing phrase like `noreply@tiktok`) in this field.
* Proxy: Optional configuration for the IP address to send connection requests to the Microsoft server to avoid IP duplication when checking emails in bulk. You can set up:
  * *Leave blank*: Use the original network of the computer running.
  * *Fill in the variable `$profileProxy`*: The system will automatically select the Proxy assigned specifically for the current GPM Profile to use.
  * *Manually enter proxy*: Directly enter the designated Proxy string in the format `ip:port` or `ip:port:user:pass`.
* Code type: The format structure of the OTP that the system needs to extract from the email content. It includes 3 options:
  1. Number: Use when the OTP sent is entirely a sequence of numbers.
     * *Code Length*: The length of the OTP string to be read (For example, if the code sent is `475997` ➔ Enter Code length as `6`).
  2. Text: Use when the OTP contains both letters and numbers, or is hidden within the HTML tag structure of the email.
     * *Code element xpath*: The XPath path directly to the element containing the OTP needed from the email content.
     * *Code element attribute*: Enter the word `text` if the OTP is the content between two tags (For example: `<h1>ABCDEF</h1>` ➔ Enter `text`). Or enter the *Attribute name* if the OTP is the value inside the attribute of the tag (For example: `<h1 @code="ABCDEF"></h1>` ➔ Enter `code`).
  3. Full: An advanced option that helps to extract the entire source code or HTML code of the returned email assigned to the output variable. After that, you can pass this variable through Regex actions or Execute JS code to write flexible extraction rules according to your own needs.
* Output variable: The name of the output variable used to store the OTP string (or the entire email content depending on the *Code type* configuration) for subsequent input actions in the script.

<figure><img src="/files/fVhcUPeCoLPUutbED6Hs" alt=""><figcaption></figcaption></figure>


---

# 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-en/action-guides/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.
