notifications
This module contains functionality for sending email messages. These messages are independent from the notification scheme that is used for subscriptions to issue updates in YouTrack. All of the components for these email messages are defined in the parameters for the function that is supported in this module. However, the messages are still sent by the SMTP server that is connected to your YouTrack installation.
Functions
sendEmail
static sendEmail(message, message.fromName, message.toEmails, message.subject, message.body, issue)
Sends an email message to one or more email addresses.
Parameters
Name | Type | Description |
---|---|---|
message | | An object that contains all of the message components that are required for sendout. |
message.fromName | | The visible name of the sender. If the value for this parameter is not specified, the sender email address is supplied by the system. If the project that the issue belongs to uses a dedicated project 'From' email, this address is used. Otherwise, the default server 'From' address is taken. |
message.toEmails | | A list of recipient email addresses. The first email address in the array is set as the recipient. All others are set as CC. |
message.subject | | The email message subject. |
message.body | | The email message body. |
issue | | The issue that the email message is related to. All email messages that are related to a single issue are combined into one thread. |
Example
var issue = ctx.issue;
if (issue.comments.added.isNotEmpty()) {
var authorName = issue.comments.added.first().author.fullName;
var message = {
fromName: authorName,
toEmails: ['user1@jetbrains.com', 'user2@jetbrains.com'],
subject: 'New comment in ' + issue.id,
body: [
'<div style="font-family: sans-serif">',
' <div style="padding: 10px 10px; font-size: 13px; border-bottom: 1px solid #D4D5D6;">',
' New comment was added in issue ' + issue.id + ' by ' + authorName,
' </div>',
'<\div>'
].join('\n');
};
notifications.sendEmail(message, issue);
}