Skip to main content

Email

Send emails through a configured Email Service. Access the service via services.YourEmailServiceName.


At a Glance

// Simple text email
services.EmailService.Send({
toList: '[email protected]',
subject: 'Order Confirmation',
body: 'Your order has been processed.'
});

// HTML email with multiple recipients
services.EmailService.Send({
from: {
Address: '[email protected]',
PersonalName: 'Company System'
},
to: [
{ Address: '[email protected]', PersonalName: 'User One' },
{ Address: '[email protected]', PersonalName: 'User Two' }
],
cc: [{ Address: '[email protected]' }],
subject: 'Monthly Report',
body: '<h1>Report</h1><p>See attachment.</p>'
});

Send(params)

Sends an email. Two addressing styles are supported — don't mix similar properties (e.g., use to or toList, not both).

Simple Address Strings

ParameterTypeDescription
fromstringSender email address
toListstringSemicolon-separated recipient addresses
ccListstring (optional)Semicolon-separated CC addresses
bccListstring (optional)Semicolon-separated BCC addresses
subjectstringEmail subject
bodystringEmail body (text or HTML)
services.EmailService.Send({
ccList: '[email protected]',
subject: 'Alert: High Error Rate',
body: `Errors in last hour: ${errorCount}`
});

Structured Addresses

ParameterTypeDescription
fromobject{ Address, PersonalName }
toobject[]Array of { Address, PersonalName }
ccobject[] (optional)Array of { Address, PersonalName }
bccobject[] (optional)Array of { Address, PersonalName }
subjectstringEmail subject
bodystringEmail body
services.EmailService.Send({
from: {
Address: '[email protected]',
PersonalName: 'Order System'
},
to: [{
Address: '[email protected]',
PersonalName: 'John Doe'
}],
subject: 'Order #12345 Confirmed',
body: 'Thank you for your order!'
});

Complete Example

export function onMessage() {
const orderId = message.getString(dataDictionary.type.Order.ID);
const customerEmail = message.getString(dataDictionary.type.Order.CUSTOMER_EMAIL);

// Send confirmation
services.EmailService.Send({
toList: customerEmail,
subject: `Order ${orderId} Confirmed`,
body: `Your order ${orderId} has been received and is being processed.`
});

stream.emit(message, OUTPUT_PORT);
}

See Also