Skip to main content

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

ParameterTypeDescription
emailOptionsObjectA JSON object containing email parameters and options

emailOptions Properties

PropertyTypeDescription
toArrayArray of recipient email addresses
ccArrayArray of carbon copy email addresses
bccArrayArray of blind carbon copy email addresses
textStringThe email body content (supports HTML formatting)
subjectStringThe email subject line
fromStringThe sender's email address
replyToStringThe email address to use for replies
autoSendBooleanWhen set to true, sends the email automatically without showing a dialog (default: false)
hideToEmailBooleanWhen set to true, hides the recipient field in the email dialog
attachmentIdsArrayArray of attachment IDs to include with the email
attachmentBlobsArrayArray of blob objects to include as attachments, format: {name: "filename.ext", blob: blobObject}
recordIdString/NumberID of the record to attach the email to (if not specified, uses the current record ID)
appNameStringName 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"
});