Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Send custom email Using ScriptRunner based on Filter Condition results



I am completely new to JIRA administration, we are using script runner to schedule different jobs, and one of the requirement is, based on the certain filter condition results, a job needs to be scheduled on certain time frame to send email with the customized body, JIRA ticket number etc,. 

What i have tested so far is just simple email sending code which is as follows..



import com.atlassian.mail.Email
import com.atlassian.mail.server.SMTPMailServer
import com.atlassian.jira.component.ComponentAccessor

def emailSubject = "JIRA CHECK"
def emailBody = "Test CHECK"
def emailAddress = "<emaild id>"

SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()

if (mailServer) {
Email email = new Email(emailAddress)
} else {}

4 answers

1 accepted

0 votes
Answer accepted

Hello Helmy


Sorry about the late reply, i would try your option and let you know whether it helps. 

I already have an flter_id eg 123, i want to see whether 123 returns me any result, if yes, then with the content of the Customized email message, i want to send to the respective recipients.


Thank You.

Hi Nagappan,

We don't yet support customized bodies, but we support everything else you said out of the box with Notification Assistant for Jira (a Staff Pick).  And we have customized notification templates coming in the next month! 

Hi Nagppan,

Thank you for using ScriptRunner.

Can you clarify what you meant by "Filter Condition"? Providing examples would help too!

As for the scheduled script, you could use Script Jobs by ScriptRunner. It accepts cron expression to define the interval a job is run at.

Hi Helmy


For example 

issuetype = Issue AND status in ("In Progress", Open) and created < -10w


I want to scan the results from the above filer (have saved the filter too and have the filter id with me), and if the filter returns any result, then would like to sent Email to certain email id.

Hi Nagppan,

You can execute a JQL query in your code and then do a simple checking:

if (search.results) {
// send email

I hope this helps!

Hello Helmy


Thanks for the link, it really helped and i was able to send the custom email. 

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you