Hey!
I use the ScriptRunner version 6.56.0 in Jira server version 8.20.9. Please tell me how you can implement sending a mail notifications with the attachment of new files from the issue? Using the built-in script “Send a custom email” it turns out to be done, but I would like to implement it in a “Custom listener”
Best regards,
Artem Vasilyev
Hey, this code can be a start, but doesn’t have the attachment part
import com.atlassian.mail.Email
import com.atlassian.mail.server.SMTPMailServer
try {
SMTPMailServer mailServer = ComponentAccessor.mailServerManager.defaultSMTPMailServer
if (mailServer) {
Email email = new Email(emailAddress)
email.setSubject(subject)
email.setBody(body)
email.setMimeType("text/html")
mailServer.send(email)
log.info("Email sent to ${emailAddress}")
}
} catch (Exception e) {
log.error(e.properties)
log.error("Error occurred when sending mail ${e.message}")
}