composeEmail
Opens an email compose dialog or automatically sends an email with the provided parameters. This function allows for creating and sending emails directly from your brixxbox application with various options including attachments.
Syntax
app.composeEmail(emailOptions)
Parameters
Parameter | Type | Description |
---|---|---|
emailOptions | Object | A JSON object containing email parameters and options |
emailOptions Properties
Property | Type | Description |
---|---|---|
to | Array | Array of recipient email addresses |
cc | Array | Array of carbon copy email addresses |
bcc | Array | Array of blind carbon copy email addresses |
text | String | The email body content (supports HTML formatting) |
subject | String | The email subject line |
from | String | The sender's email address |
replyTo | String | The email address to use for replies |
autoSend | Boolean | When set to true, sends the email automatically without showing a dialog (default: false) |
hideToEmail | Boolean | When set to true, hides the recipient field in the email dialog |
attachmentIds | Array | Array of attachment IDs to include with the email |
attachmentBlobs | Array | Array of blob objects to include as attachments, format: {name: "filename.ext", blob: blobObject} |
recordId | String/Number | ID of the record to attach the email to (if not specified, uses the current record ID) |
appName | String | Name of the app to associate with the email (if not specified, uses the current app name) |
Return Value
This method doesn't return a value.
Description
The composeEmail
function provides a flexible way to create and send emails from your brixxbox application. It can either open a dialog for users to edit and review the email before sending, or automatically send emails without user intervention.
The function automatically normalizes email addresses if they are provided as comma-separated strings. It also supports various attachment options, including existing attachment IDs or blob objects generated at runtime.
Examples
Basic Usage
app.composeEmail({
text: "This is the message text",
to: ["john.doe@acme.com"],
subject: "Important notification"
});
Email with HTML Content and Multiple Recipients
app.composeEmail({
text: `<h2>Meeting Reminder</h2>
<p>This is to remind you about our meeting tomorrow at 2 PM.</p>
<p>Please bring the <strong>quarterly report</strong>.</p>
<p>Check our website: <a href='http://www.example.com'>www.example.com</a></p>`,
to: ["john.doe@acme.com", "jane.doe@acme.com"],
cc: ["manager@acme.com"],
subject: "Meeting Reminder - Tomorrow 2 PM",
from: "noreply@acme.com"
});
Automatic Email Sending
app.composeEmail({
text: "Your order has been processed successfully.",
to: ["customer@example.com"],
subject: "Order Confirmation #12345",
from: "orders@acme.com",
replyTo: "support@acme.com",
autoSend: true
});
Email with PDF Attachments
app.composeEmail({
text: "Please find attached the requested documents.",
to: ["client@example.com"],
subject: "Your Requested Documents",
attachmentBlobs: [
{
name: "Report.pdf",
blob: app.createReport("monthlyReport")
},
{
name: "Invoice.pdf",
blob: app.createReport("invoice")
}
]
});
Email with Existing Attachments
app.composeEmail({
text: "Here are the files you requested.",
to: ["partner@example.com"],
subject: "Requested Files",
attachmentIds: [42, 57, 63]
});
Email Associated with a Record
app.composeEmail({
text: "Your account information has been updated.",
to: ["user@example.com"],
subject: "Account Update Confirmation",
recordId: 1234,
appName: "UserManagement"
});
Related Functions
- createReport - Creates a report that can be attached to emails
- getAttachmentById - Retrieves an attachment by ID for attaching to emails