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.ComponentAccessor
import com.atlassian.mail.Email
import com.atlassian.mail.MailException
import com.atlassian.mail.MailFactory
import com.atlassian.mail.queue.SingleMailQueueItem
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer
MailServerManager mailServerManager = ComponentAccessor.mailServerManager
SMTPMailServer mailServer = mailServerManager.defaultSMTPMailServer
if (!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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.