> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Email

> Class for representing and sending emails.

Class for representing and sending emails.

## Constructors

### Email()

```crmscript theme={null}
Email
```

Initializes a new instance of the Email class.

## Methods

## addAttachment(Integer,Bool)

Adds an attachment to the email object.

```crmscript theme={null}
String addAttachment(Integer attachmentId, Bool inline)
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The ID of the attachment relative to the email.

## send()

Sends the email.

```crmscript theme={null}
Void send()
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## setValue(String,String)

Sets the value of the given field in the email instance.

For multiple recipients, call setValue multiple times, once for each recipient.

```crmscript theme={null}
Void setValue(String name, String value)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  Available fields:

  * from: The from address.
  * to: The recipient.
  * cc: The carbon copy recipient.
  * bcc: The bcc recipient.
  * sms: A cellphone number to send sms to.
  * smsFrom: The from address when sending sms.
  * subject: The subject of the email.
  * body: The plain text body of the email.
  * bodyHtml: The HTML formated body of the email.
  * ticketId: The ticketId, only used with sms.\</p
  * envelopeFrom
  * Sets the envelope from mail address. "From" will also be set if not already set

  \>\<p>From version 8.1 any other header value may also be added, for example setValue("X-Foo", "42");
</Note>


## Related topics

- [Email](/en/email/learn/index.md)
- [Service emails](/en/email/admin/mailbox/index.md)
- [Email filters](/en/email/admin/mailbox/create-email-filter.md)
- [Compose email](/en/email/inbox/learn/compose.md)
- [Delete Emails](/en/api/reference/restful/agent/email_agent/delete-emails.md)
- [Email table](/en/database/tables/email.md)
