# ReadEmail

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.Exchange>

{% tabs %}
{% tab title="Parameter: Connection" %}

| Name                                               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AuthenticationProvider : `AuthenticationProviders` | <p>Specifies the type of authentication provider to use for the connection.</p><p>Possible values:</p><ul><li><code>ClientCredentialsCertificate</code>:</li></ul><p>Specifies the type of authentication provider to use for the connection.</p><ul><li><code>ClientCredentialsSecret</code>:</li></ul><p>Specifies the type of authentication provider to use for the connection.</p><ul><li><code>UsernamePassword</code>:</li></ul><p>Specifies the type of authentication provider to use for the connection.</p><p><br>Default: <code>2</code><br>Example: <code>AuthenticationProviders.UsernamePassword</code></p> |
| X509CertificateFilePath : `String`                 | <p>Specifies the path to a file that contains both the client certificate and private key.</p><p><br>Default: <code>-</code><br>Example: <code>C:\Certificates\mycert.pfx</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| 🗝ClientSecret : `String`                          | <p>Specifies the secret key of the client application.</p><p><br>Default: <code>-</code><br>Example: <code>Y2lzY29zeXN0ZW1zOmMxc2Nv</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Username : `String`                                | <p>Specifies the username of the user.</p><p><br>Default: <code>-</code><br>Example: <code><johndoe@example.com></code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| 🗝Password : `String`                              | <p>Specifies the password of the user.</p><p><br>Default: <code>-</code><br>Example: <code>SecurePassword123</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ClientId : `String`                                | <p>Specifies the app ID for fetching an access token.</p><p>This is the unique identifier for your application.</p><p><br>Default: <code>-</code><br>Example: <code>4a1aa1d9-c16a-40a2-bd7d-2bd40babe4ff</code></p>                                                                                                                                                                                                                                                                                                                                                                                                        |
| TenantId : `String`                                | <p>Specifies the tenant ID for fetching an access token.</p><p>This is the unique identifier of your Azure AD tenant.</p><p><br>Default: <code>-</code><br>Example: <code>9188040d-6c67-4c5b-b112-36a304b66dad</code></p>                                                                                                                                                                                                                                                                                                                                                                                                  |
| {% endtab %}                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

{% tab title="Parameter: Input" %}

| Name                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| From : `String`                        | <p>User entity to get emails from. Can be left empty to use default user.</p><p><br>Default: <code>-</code><br>Example: <code><johndoe@example.com></code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Select : `String`                      | <p>Select properties to be returned.</p><p><br>Default: <code>-</code><br>Example: <code>subject,body,bodyPreview,uniqueBody,hasAttachments</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Filter : `String`                      | <p>Filter items by property values.</p><p><br>Default: <code>-</code><br>Example: <code>parentFolderId eq 'INBOX' and from/emailAddress/address eq '<user@exampledomain.com>' and subject eq 'This is subject' and isRead eq true and hasAttachments eq true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Skip : `Nullable<Int32>`               | <p>Skip the first n items.</p><p><br>Default: <code>-</code><br>Example: <code>10</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Top : `Int32`                          | <p>Limits the result to the first n items. If set to 0, all items are returned.</p><p><br>Default: <code>0</code><br>Example: <code>10</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| Orderby : `String`                     | <p>Order items by property values.</p><p><br>Default: <code>-</code><br>Example: <code>receivedDateTime DESC,subject ASC</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Expand : `String`                      | <p>Expand related entities.</p><p><br>Default: <code>-</code><br>Example: <code>attachments</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| UpdateReadStatus : `Boolean`           | <p>Specifies whether to mark an email as read after processing it. If set to true, the email will be marked as read in the mailbox. If set to false, the email's read status will remain unchanged.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| Headers : `HeaderParameters[]`         | <p>Header parameters.</p><p><br>Default: <code>-</code><br>Example: <code>{ \[ "Prefer", "outlook.body-content-type="text"" ] }</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| DownloadAttachments : `Boolean`        | <p>Specifies whether to download attachments.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| DestinationDirectory : `String`        | <p>Specifies the directory where the downloaded attachments will be stored.</p><p><br>Default: <code>-</code><br>Example: <code>C:\Users\username\Downloads</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| CreateDirectory : `Boolean`            | <p>Create directory where the downloaded attachments will be stored.</p><p><br>Default: <code>-</code><br>Example: <code>-</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| FileExistHandler : `FileExistHandlers` | <p>Specifies the action to take when a file with the same name already exists in the destination directory.</p><p>If FileExistHandler.Rename is selected, an unique number will be appended to the name of the file to be downloaded (e.g., file(2).txt).</p><p>Possible values:</p><ul><li><code>Skip</code>:</li></ul><p>Specifies the action to take when a file with the same name already exists in the destination directory.</p><p>If FileExistHandler.Rename is selected, an unique number will be appended to the name of the file to be downloaded (e.g., file(2).txt).</p><ul><li><code>Rename</code>:</li></ul><p>Specifies the action to take when a file with the same name already exists in the destination directory.</p><p>If FileExistHandler.Rename is selected, an unique number will be appended to the name of the file to be downloaded (e.g., file(2).txt).</p><ul><li><code>Append</code>:</li></ul><p>Specifies the action to take when a file with the same name already exists in the destination directory.</p><p>If FileExistHandler.Rename is selected, an unique number will be appended to the name of the file to be downloaded (e.g., file(2).txt).</p><ul><li><code>OverWrite</code>:</li></ul><p>Specifies the action to take when a file with the same name already exists in the destination directory.</p><p>If FileExistHandler.Rename is selected, an unique number will be appended to the name of the file to be downloaded (e.g., file(2).txt).</p><p><br>Default: <code>0</code><br>Example: <code>FileExistHandlers.Skip</code></p> |
| {% endtab %}                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

{% tab title="Parameter: Options" %}

| Name                                | Description                                                                                                                                                                                                                                                                                                                                                                                       |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| DeleteReadEmails : `Boolean`        | <p>If true, then received emails will be hard deleted.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                   |
| ThrowExceptionOnFailure : `Boolean` | <p>Gets or sets a value indicating whether an error should stop the task and throw an exception.</p><p>If set to true, an exception will be thrown when an error occurs. If set to false, Task will try to continue and the error message will be added into Result.ErrorMessages and Result.Success will be set to false.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p> |
| {% endtab %}                        |                                                                                                                                                                                                                                                                                                                                                                                                   |

{% tab title="Result: Result" %}

| Name                           | Description                                                                                                                                                                                                                                                          |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`            | <p>Gets a value indicating whether the task was executed successfully.<br>Example: <code>true</code></p>                                                                                                                                                             |
| Data : `List<ResultObject>`    | <p>Gets the result of the task. Contains exception message if exception was thrown and Options.ThrowExceptionOnFailure = false.<br>Example: <code>{ "AAMkADIxYTJiZDIz", "C:\temp\file.txt", 6000, "#microsoft.graph.fileAttachment", "This is content." }</code></p> |
| ErrorMessages : `List<Object>` | <p>Error messages.<br>Example: <code>{ "error occured", "another error occured." }</code></p>                                                                                                                                                                        |
| {% endtab %}                   |                                                                                                                                                                                                                                                                      |

{% tab title="Changelog" %}

## Changelog

### \[1.4.0] - 2026-03-20

#### Added

* Added DeleteReadEmails option to permanently delete emails after they are read and processed.

### \[1.3.0] - 2025-10-17

#### Changed

* Changed ClientSecret to a password property.

### \[1.2.0] - 2024-08-22

#### Changed

* Updated the Azure.Identity, Newtonsoft.Json and Mimekit libraries to their latest versions.

### \[1.1.0] - 2023-05-24

#### Fixed

* Skip parameter is null instead of zero when it is not supported

### \[1.0.0] - 2023-05-12

#### Added

* Initial implementation
  {% endtab %}
  {% endtabs %}
