The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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)
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.