> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/end-user-and-partner-section/end-user-section/how-to-import-documents/email/oauth-office365.md).

# OAuth Office365

{% embed url="<https://youtu.be/Vvy38N_5g3Y>" %}

Here you just need to enter your desired sub organization and press ‘Authenticate’

<figure><img src="https://578966019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT2n2w4uDCJvv7CJ5zrdk%2Fuploads%2Fgit-blob-652fb882b8854448ffd7d6e6b3e0eaa603244f43%2Fa-email-oauth-office365-authenticate-en-20261006.png?alt=media" alt="Email Server Setup dialog with protocol OAuth Office365, Document Routing and the Authenticate button."><figcaption><p>Choose the routing and press Authenticate.</p></figcaption></figure>

You will be taken to this Microsoft page and you will need to enter a code.

![Microsoft sign-in page asking to enter the code displayed on the app or device](https://lh7-us.googleusercontent.com/Q76mIMXr5bWCrcu_6TOKDrh6yQIMESIrFvEcfvqg7mJp-K_4ES2e5ekPY4Ghhwxym-uRKz_QVCHyqk2u5onyoCCmg7fMbt3mnIUyCrc8XT4jBGn9ueEYij3DRg1-oODWHd-vDfM9FfbU3omF6RJJKsE)

This code can be found by clicking back to DocBits and the code will be displayed there like below, simply copy the code and enter it into the Microsoft page. Thereafter you will need to enter your own Microsoft credentials.

<figure><img src="https://578966019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT2n2w4uDCJvv7CJ5zrdk%2Fuploads%2Fgit-blob-94bb118fdad1052b88171e38ca83fa93c262e898%2Fa-email-oauth-office365-code-en-20261006.png?alt=media" alt="Email Server Setup dialog showing the Microsoft authentication code with a Copy button and the Finish authentication button."><figcaption><p>The Microsoft code is displayed in DocBits.</p></figcaption></figure>

Press the FINISH AUTHENTICATION button and you will be taken to this menu

<figure><img src="https://578966019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT2n2w4uDCJvv7CJ5zrdk%2Fuploads%2Fgit-blob-de85c6745852e0d2a9553ea2a90fa5c82d5b0012%2Fa-email-oauth-office365-options-en-20261006.png?alt=media" alt="Email Server Setup dialog after authentication with the switches Use Folder, Use Shared Mailbox and Move Emails To Other Folder."><figcaption><p>Options after the authentication is finished.</p></figcaption></figure>

**Use Folder**

If you are using a folder other than your inbox, enter the folder name after enabling the slider.

**Use Shared Mailbox**

If you want the email import to access an inbox or a folder of a shared mailbox, input the email address here after enabling the slider.

**Move imported emails to trash**

If you want to import all emails, not just the unread ones, and have them moved to trash then activate this. If not, it will only check for unread emails, import the documents, set the email to read and leave it in its current place.

In the event of you receiving an error message indicating you do not have the rights to establish such a connection, someone with admin rights within Azure would need to authorize this connection. For more information, visit the following page: <https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/grant-admin-consent?pivots=portal#grant-tenant-wide-admin-consent-in-enterprise-apps>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.docbits.com/end-user-and-partner-section/end-user-section/how-to-import-documents/email/oauth-office365.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
