# SendEmail

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.SMTP/tree/main/Frends.SMTP.SendEmail>

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

| Name                       | Description                                                                                                                                                                                                                                                    |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| To : `String`              | <p>Recipient addresses separated by ',' or ';'</p><p><br>Default: <code><jane.doe@somedomain.com></code><br>Example: <code><jane.doe@somedomain.com></code></p>                                                                                                |
| Cc : `String`              | <p>Cc recipient addresses separated by ',' or ';'</p><p><br>Default: <code><jane.doe@somedomain.com></code><br>Example: <code><jane.doe@somedomain.com></code></p>                                                                                             |
| Bcc : `String`             | <p>Bcc recipient addresses separated by ',' or ';'</p><p><br>Default: <code><jane.doe@somedomain.com></code><br>Example: <code><jane.doe@somedomain.com></code></p>                                                                                            |
| From : `String`            | <p>Sender address.</p><p><br>Default: <code><john.doe@somedomain.com></code><br>Example: <code><jane.doe@somedomain.com></code></p>                                                                                                                            |
| SenderName : `String`      | <p>Name of the sender.</p><p><br>Default: <code>-</code><br>Example: <code>Jane Doe</code></p>                                                                                                                                                                 |
| Subject : `String`         | <p>Email message's subject.</p><p><br>Default: <code>Hello Jane</code><br>Example: <code>Hello Jane</code></p>                                                                                                                                                 |
| Message : `String`         | <p>Body of the message.</p><p><br>Default: <code>You've got mail!</code><br>Example: <code>You've got mail!</code></p>                                                                                                                                         |
| IsMessageHtml : `Boolean`  | <p>Set this true if the message is HTML.</p><p><br>Default: <code>false</code><br>Example: <code>true</code></p>                                                                                                                                               |
| MessageEncoding : `String` | <p>Encoding of message body and subject. Use following table's name column for other options. <https://msdn.microsoft.com/en-us/library/system.text.encoding(v=vs.110).aspx#Anchor_5></p><p><br>Default: <code>utf-8</code><br>Example: <code>utf-8</code></p> |
| {% endtab %}               |                                                                                                                                                                                                                                                                |

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

| Name                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Attachments : `Attachment[]` | <p>Array of Attachments to be send with the message.</p><p><br>Default: <code>-</code><br>Example: <code>\[ Attachment { AttachmentType = AttachmentType.FileAttachment, FilePath = C:\pathToTheFile\test.txt, SendIfNoAttachmentsFound = false, ThrowExceptionIfAttachmentNotFound = true }, Attachment { AttachmentType = AttachmentType.AttachmentFromString, AttachmentFromString { FileContent = This is test file, FileName = testfile.txt } } ]</code></p> |
| {% endtab %}                 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

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

| Name                                       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SMTPServer : `String`                      | <p>SMTP server address.</p><p><br>Default: <code>smtp.somedomain.com</code><br>Example: <code>smtp.somedomain.com</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Port : `Int32`                             | <p>SMTP server port.</p><p><br>Default: <code>25</code><br>Example: <code>25</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| SecureSocket : `SecureSocketOption`        | <p>Choose the SecureSocketOption to use, default is Auto</p><p>Possible values:</p><ul><li><code>None</code>:</li></ul><p>Choose the SecureSocketOption to use, default is Auto</p><ul><li><code>Auto</code>:</li></ul><p>Choose the SecureSocketOption to use, default is Auto</p><ul><li><code>SslOnConnect</code>:</li></ul><p>Choose the SecureSocketOption to use, default is Auto</p><ul><li><code>StartTls</code>:</li></ul><p>Choose the SecureSocketOption to use, default is Auto</p><ul><li><code>StartTlsWhenAvailable</code>:</li></ul><p>Choose the SecureSocketOption to use, default is Auto</p><p><br>Default: <code>1</code><br>Example: <code>SecureSocketOption.None</code></p> |
| AcceptAllCerts : `Boolean`                 | <p>WARNING: Setting AcceptAllCerts to true disables SSL/TLS certificate validation.</p><p>This should only be used in development/test environments with self-signed certificates.</p><p>Using this option in production environments poses significant security risks.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                    |
| UseOAuth2 : `Boolean`                      | <p>Set this true if SMTP server expectes OAuth token.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| 🗝Token : `String`                         | <p>Token to be used when using OAuth2.</p><p><br>Default: <code>-</code><br>Example: <code>cec4ce4f98e4f68e4vc89v1489v4987s4erv8794...</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| UserName : `String`                        | <p>Use this username to log in to the SMTP server</p><p><br>Default: <code>-</code><br>Example: <code>testuser</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 🗝Password : `String`                      | <p>Use this password to log in to the SMTP server</p><p><br>Default: <code>-</code><br>Example: <code>Password123</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| 🗝ServerCertificationThumbprint : `String` | <p>The SHA-1 thumbprint of the server's SSL certificate.</p><p>This provides a secure way to validate the server's identity without accepting all certificates.</p><p>How to obtain the thumbprint:</p><p>1. View the server's certificate in a browser</p><p>2. Open certificate details</p><p>3. Copy the SHA-1 fingerprint/thumbprint</p><p>Format: 40 hexadecimal characters (20 bytes)</p><p><br>Default: <code>-</code><br>Example: <code>a1b2c3d4e5f6g7h8i9j0...</code></p>                                                                                                                                                                                                                  |
| {% endtab %}                               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

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

| Name                    | Description                                                                                                            |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| EmailSent : `Boolean`   | <p>Value is true if email was sent.<br>Example: <code>true</code></p>                                                  |
| StatusString : `String` | <p>Contains information about the task's result.<br>Example: <code>Email sent to: <john.doe@somedomain.com></code></p> |
| {% endtab %}            |                                                                                                                        |

{% tab title="Changelog" %}

## Changelog

### \[2.1.0] - 2025-12-08

#### Fixed

* Fix missing metadata about repository url and changelog.

### \[2.0.0] - 2024-09-30

#### Added

* \[Breaking] Added parameter AcceptAllCerts which allows bypassing SSL/TLS certificate validation for SMTP servers.
  * Default value: false
  * Warning: Enabling this option poses security risks. Only use when connecting to trusted SMTP servers with self-signed certificates.
  * Usage: Enable only in controlled environments where certificate validation issues cannot be resolved through proper certificate installation.
* \[Breaking] Added parameter ServerCertificationThumbprint which enables check for the certification thumbprint.
  * Default value: ""

### \[1.2.1] - 2024-01-02

#### Fixed

* Fixed issue with connecting to SMTP servers which do not support authentication.

### \[1.2.0] - 2023-12-21

#### Changed

* Changed Task to use MailKit library instead of deprecated System.Net.Mail.
* Changed the Task to create a temp file from the AttachmentFromString. The temp file will be removed afterwards.

#### Added

* Added OAuth2 support.
* New parameters:
  * SecureSocket
  * UseOAuth2
  * Token

#### Removed

* Removed UseWindowsAuthentication because it's not supported with the new library.

### \[1.1.0] - 2023-11-29

#### Fixed

* \[Breaking] Fixed issue with the attachments can't be given as expression by adding AttachmentOptions class.

### \[1.0.3] - 2023-11-03

#### Added

* Fix missing XML comments.

### \[1.0.2] - 2023-11-03

#### Added

* Fix bug #20 - Missing Frends tasks metadata file

### \[1.0.1] - 2023-05-15

#### Fixed

* Fix bug #14 - NullReferenceException when field with 'Expression' type is empty

### \[1.0.0] - 2022-02-09

#### Added

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