# Get Emails via IMAP

Retrieve emails using the IMAP protocol.

<table data-header-hidden><thead><tr><th width="235" valign="top"></th><th width="291" valign="top"></th></tr></thead><tbody><tr><td valign="top">Server</td><td valign="top">[Text] Server (for example, <code>"imap.mail.ru"</code>).</td></tr><tr><td valign="top">Port</td><td valign="top"><p>[Number] Port. If not specified, the default port is used:</p><ul><li>standard connection - 143,</li><li>secure connection - 993.</li></ul></td></tr><tr><td valign="top">Login</td><td valign="top">[Text] Login required for authentication on the server.</td></tr><tr><td valign="top">Password</td><td valign="top">[Text/SecureString] Password required for authentication on the server.</td></tr><tr><td valign="top">Timeout</td><td valign="top">[Number] Timeout for a response from the server. The value is specified in seconds.</td></tr><tr><td valign="top">SSL</td><td valign="top">Indicates whether to use a secure connection.</td></tr><tr><td valign="top">Number of Emails</td><td valign="top">[Number] The number of recent emails to be retrieved from the server.</td></tr><tr><td valign="top">Delete After Retrieval</td><td valign="top">Delete emails from the mail server after retrieval.</td></tr><tr><td valign="top">Mark as Read</td><td valign="top">Mark emails as read after retrieval.</td></tr><tr><td valign="top">Only New</td><td valign="top">Retrieve only new emails.</td></tr><tr><td valign="top">Sort by Date</td><td valign="top"><p>Type of sorting by date.</p><p>Possible options:</p><ul><li>NewestFirst - new messages will be first in the list;</li><li>OldestFirst - old messages will be first in the list.</li></ul></td></tr><tr><td valign="top">Email Header Filter</td><td valign="top">[Text] Email header filter. The filter format depends on the "Email Header Filter Type" property.</td></tr><tr><td valign="top">Email Header Filter Type</td><td valign="top"><p>Type of email header filter. Possible values:</p><ul><li>Contains - simple text content check (this check occurs on the server and is the fastest);</li><li>Wildcard - use of wildcard characters (*, ?);</li><li>Regex - use of regular expressions.</li></ul><p>Wildcard and Regex filters are executed after emails are retrieved and are the most resource-intensive. It is recommended to use them only with the "Only New" property set.</p></td></tr><tr><td valign="top">Folder</td><td valign="top"><p>[Text] Folder on the mail server for receiving mail. If the value is empty, the "Inbox" folder will be used.</p><p>If necessary, specify nested folders using the <code>'\'</code> character. For example, <code>"Inbox\TestFolder"</code>.</p></td></tr><tr><td valign="top">Result</td><td valign="top">[List] List of MailMessage objects that are emails with all content.</td></tr><tr><td valign="top">Error Handling Level</td><td valign="top"><p>Select the error handling level. Possible values:</p><ul><li>"Default" - default;</li><li>"Ignore" - errors are ignored;</li><li>"Handle" - errors are handled.</li></ul><p>If "Default" is selected, the value from the "Start" block of this diagram will be used.</p></td></tr><tr><td valign="top">Message Level</td><td valign="top"><p>Select the message level that blocks will output during operation. Possible values:</p><ul><li>"Default" - default;</li><li>"Release" - output is disabled;</li><li>"Debug" - outputs main information;</li><li>"Detailed" - outputs detailed information.</li></ul><p>If "Default" is selected, the value from the "Start" block of this diagram will be used.</p></td></tr><tr><td valign="top">Error Text</td><td valign="top">[Text] Returns detailed information about the error in case of incorrect execution of the block's work.</td></tr></tbody></table>


---

# 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.sherparpa.ru/en/sherpa-rpa/sherpa-designer/spravochnik-blokov/elektronnaya-pochta-mail/poluchit-pisma-cherez-imap-getimapmailmessages.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.
