Skip to main content

Email


id: py-Email

Email

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


At a Glance

# Simple text email
services.EmailService.send({
"from": "[email protected]",
"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
fromstrSender email address
toListstrSemicolon-separated recipient addresses
ccListstr (optional)Semicolon-separated CC addresses
bccListstr (optional)Semicolon-separated BCC addresses
subjectstrEmail subject
bodystrEmail body (text or HTML)
services.EmailService.send({
"from": "[email protected]",
"ccList": "[email protected]",
"subject": "Alert: High Error Rate",
"body": f"Errors in last hour: {error_count}"
})

Structured Addresses

ParameterTypeDescription
fromdict{"Address": str, "PersonalName": str}
toList[dict]Array of {"Address": str, "PersonalName": str}
ccList[dict] (optional)Array of {"Address": str, "PersonalName": str}
bccList[dict] (optional)Array of {"Address": str, "PersonalName": str}
subjectstrEmail subject
bodystrEmail 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

def on_message():
order_id = message.getString(dataDictionary.type.Order.ID)
customer_email = message.getString(dataDictionary.type.Order.CUSTOMER_EMAIL)

# Send confirmation
services.EmailService.send({
"from": "[email protected]",
"toList": customer_email,
"subject": f"Order {order_id} Confirmed",
"body": f"Your order {order_id} has been received and is being processed."
})

stream.emit(message, OUTPUT_PORT)

See Also