# Get Mail

This activity retrieves email messages that match the given criteria from a user-specified mailbox using the Microsoft Graph [Get Message](https://docs.microsoft.com/en-us/graph/api/message-get?view=graph-rest-1.0\&tabs=http) and [List Messages](https://docs.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0\&tabs=http) APIs.

### Input

* **Connection Id:** [`GraphServiceClient Variable`](/getting-started/rpa-studio/variables.md#graphserviceclient)![](/files/-MVREnwPf_D3-qJvjjYd)\
  Specifies the office 365 connection id.
* **Account:** [`String Argument`](/getting-started/rpa-studio/arguments.md#string)\
  Specifies an email address with which to interact. This property can include any shared mailbox to which the current user has access rights. If the property field is left empty, the current user's account is used. This is an **optional** property.
* **Mail Folder:** [`String Argument`](/getting-started/rpa-studio/arguments.md#string) ![](/files/-MVREnwPf_D3-qJvjjYd)\
  Specifies the mail folder from which the messages are retrieved.

### Options

* **Get As Html:**
  * `True` - The activity will return the message body in Html format.
  * `False` - The message body will be returned in Text format.
* **Mark As Read:**
  * `True` - The activity will mark the retrieved messages as reads.
  * `False` - The retrieved messages will remain unread.
* **Only Unread Messages:**
  * `True` - The activity will retrieve only unread messages.
  * `False` - The activity retrieves all read and unread messages.
* **Filter Query:** [`String Argument`](/getting-started/rpa-studio/arguments.md#types-of-arguments)\
  Specifies the query used for filtering the emails that are to be retrieved. The query input can be given using the [OData query parameter](https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter). For example: *"subject eq 'Test Subject'".*
* **Limit:** [`Integer Argument`](/getting-started/rpa-studio/arguments.md#integer)\
  Specifies the maximum number of emails to be retrieved. By default, the value is set to 5.

### Output

* **Result:** [Array Variable](/getting-started/rpa-studio/variables.md#types-of-variables)![](/files/hZwYNznPyGoqDLsH6pna)\
  The output is an array that stores all emails retrieved from the user's mailbox as [Office365Message](/getting-started/rpa-studio/variables.md#office-365-message).

{% hint style="info" %}
The output variable of this activity can be used as input for its succeeding activities like [Move Mail](/integrations/office-365/activities/outlook/move-mail.md), [Delete Mail](/integrations/office-365/activities/outlook/delete-mail.md), [Forward Mail](/integrations/office-365/activities/outlook/forward-mail.md) etc...

When using the output variable of this activity in the input properties of the other mail activities we can directly specify elements in the array that we require.For example: Messages\[0]
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://docs.visualyze.ai/integrations/office-365/activities/outlook/get-mail.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
