> For the complete documentation index, see [llms.txt](https://brixxbox.gitbook.io/brixxbox-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/composeemail.md).

# composeEmail

### Parameters

1. emailOptions - (optional) Json object with email parameters.
   * to - array of email addresses
   * cc - array of email addresses
   * bcc - array of email addresses
   * text - message text
   * subject - subject
   * from - single string with an email address
   * replyTo - single email, that will be used as to reply to
   * autoSend - if set to true, the mail will be send automatically. You will not see a dialog at all. (Default is false)
   * hideToEmail - if set to true. The recipients email address is hidden in the email dialog
   * attachmentIds - an array of attachment ids that will be sent as an attachment,
   * attachmentBlobs - an array of blobs objects that will be sent as an attachment, {name: myFileName, blob: myBlob}
   * recordId - RecordId if you would like to attach the email to an record. If empty, this is the current record Id (available from 18.11.2021)
   * appName - AppName if you would like to attach the email to an record. If empty, this is the current App Name (available from 18.11.2021)

### Example Usages

#### Example 1

Shows the dialog without any predefined values

Shows the dialog text and to addresses

```javascript
   composeEmail({
      text: `This is the messsage text and this is a link: <a href='http://www.brixxbox.net' target='_blank'>www.brixxbox.net</a>`, 
      to:["john.doe@acme.com", "jane.doe@acme.com"], 
      subject: "This is the mail subject",
      from: "noreply@acme.com"
   });
```

#### Example 2

Sends the email without a dialog

```javascript
   composeEmail({
      text: "This is the messsage text", 
      to:["john.doe@acme.com", "jane.doe@acme.com"], 
      subject: "This is the mail subject",
      from: "noreply@acme.com",
      replyTo: "reply@acmy.com", 
      autoSend: true //Set this to avoid the dialog
   });
```

#### Example 3 - attachment blobs

```javascript
   composeEmail({
      text: "This is the messsage text", 
      to:["john.doe@acme.com", "jane.doe@acme.com"], 
      subject: "This is the mail subject",
      from: "noreply@acme.com",
      autoSend: true,
      attachmentBlobs: [
         {
            name: "Test1.pdf", 
            blob: app.createReport("report")
         },
         {
            name: "Test2.pdf", 
            blob: app.getAttachmentById(2)
         }
      ],
   });
```

#### Example 4 - attachment ids

```javascript
   composeEmail({
      text: "This is the messsage text", 
      to:["john.doe@acme.com", "jane.doe@acme.com"], 
      subject: "This is the mail subject",
      from: "noreply@acme.com",
      autoSend: true,
      attachmentIds: [1, 2, 3]
   });
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/composeemail.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
