Hi,
I created a script that tracks the status of epic/sub-task and closes the parent link/initiative based on their statuses. I wanted to email the log/output of the script either as an attachment or body, how do I go about doing this?
Here is some sample code for sending an email via the default jira mail system
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.mail.Emailimport com.atlassian.mail.MailExceptionimport com.atlassian.mail.MailFactoryimport com.atlassian.mail.queue.SingleMailQueueItemimport com.atlassian.mail.server.MailServerManagerimport com.atlassian.mail.server.SMTPMailServerMailServerManager mailServerManager = ComponentAccessor.mailServerManagerSMTPMailServer mailServer = mailServerManager.defaultSMTPMailServerif (!mailServer) return "No mailServer found on this instance"if (!MailFactory.settings.sendingDisabled) return "Can't send emails while Outgoing mail is disabled"Email email = new Email('recipent1@example.com,recipient2@example.com')email.setFrom(mailServer.defaultFrom)email.subject = "your custom subject"email.body = "your body, dump your logs in here"email.mimeType = "text/plain" //or "text/html"SingleMailQueueItem item = new SingleMailQueueItem(email)ComponentAccessor.mailQueue.addItem(item)
It looks like you're new here. Sign in or register to get started.