...
Info | ||
---|---|---|
| ||
This routine is available since starting with katl-commons 1.0, changed in 1.1.14 (for JIRA Jira 4.3.x and / 4.4.x ) and 2.0.7 ( for JIRA Jira 5.x) . |
Syntax
...
sendEmail([from], to, [cc], subject, body_or_template, [language])
Since Starting with katl-commons 2.0.7, we also have support for attachments using one of two forms:
...
sendEmail(from, to, cc, subject, body_or_template, language, wildcard_path_array)
Description
...
Excerpt |
---|
Sends an email. to and cc are string arrays with any of email addresses, users or groups, in which case an email will be sent to all the users of the groups.from is optional; if missing the email will be sent from the default email address configured in JIRA. |
...
Starting from version 4.0, the engine automatically detects HTML or plain text messages.
Parameters
...
Parameter name | Type | Required | Description |
---|---|---|---|
from | string | no | the from address |
to | string [] | yes | recipient list |
cc | string [] | no | CC'ed recipient list |
subject | string | yes | subject |
body_or_template | string | yes | message body, either direct or a template |
language | string | no | the language used to send the email(relevant only if you use templates) |
issue_key | string | no | the issue to extract attachments from |
regex_array | string [] | if issue_key is present | name patterns to match the attachments from the issue |
wildcard_path_array | string [] | no | absolute paths containing wildcards for attaching files from disk |
Alias
...
For historical reasons, this routine may be named 'sendEmailFrom'
Starting with version 4.0, 'sendHtmlEmail' was registered as an alias, too (there is no need for sendHtmlEmail anymore)
Example
...
Example 1
...
Code Block |
---|
sendEmail("projectmanager", "teamleader1", "Transition executed", currentUser() + " has executed a transition"); // here we have to, cc, subject and body. // The from and language parameters were omitted. |
Example 2
...
If SendEmailLanguage has the value receiver_language, testJiraUser1 is a JIRA user having the defined language French and testJiraUser2 is a JIRA user having the defined language German
...
Result: It will be sent one email in French for testJiraUser1, one email in German for testJiraUser2 and one email in the sender defined language for testEmail@kepler.ro(as to) and testEmail2@kepler.ro(as cc).
Example 3
...
Is similar with example 2, but here the language parameter is used.
...
Result: It will be sent one email in English(because of the en_US language parameter).
Example 4
...
This example will demonstrate the ability to attach files (to the email) selected from the attachments of the issue using regex patterns.
...
Note |
---|
Don't forget to use double backslashes when escaping special characters in regex patterns. |
Example 5
...
You can also attach files directly from disk by specifying absolute paths. Note that you can also use * (anything) and ? (any single char) as wildcards.
Code Block |
---|
sendEmail("santa@kepler.ro", {"jira-users"}, {}, "santa_subject.tpl", "santa_letter.tpl", {"C:/gifts/jira-users*.gift"}); |
Notes
...
Note |
---|
If you would like to use templates for emails, see the Mail Configuration page, as well as detailed explanations linked our template engine: SIL Template Language. Specifically, read Email Templates page. |
...
Note |
---|
In order for the HTML to be rendered all right, it needs to be written right (using the <html> and <body> tags). |
See
...
also
Filter by label (Content by label) | ||||||||
---|---|---|---|---|---|---|---|---|
|
...