Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can we send a customized email via Filter Subscription

SWAPNIL SRIVASTAV
Contributor
May 18, 2020

I need to a send a customized email in every 1 hour for a particular filter

2 answers

0 votes
Boris Berenberg - Atlas Authority
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2020

If you would like to do to this without writing code, you can do this using our app Notification Assistant for Jira https://marketplace.atlassian.com/apps/1211069/notification-assistant-for-jira-email?hosting=server&tab=overview

0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 24, 2020

If you really need something completely custom, yeah, it's possible but it requires a lot of scriptrunner skills.

You'll need to:

Create a custom job to run every hour
Have your script run the JQL and handle the results
The script will need to construct the email body and dynamically identify recipients if applicable
But here is a sample script to send an email:

import com.atlassian.mail.Email
import com.atlassian.mail.MailException
import com.atlassian.mail.MailFactory
import com.atlassian.mail.queue.SingleMailQueueItem
import com.atlassian.jira.component.ComponentAccessor

def mailServerManager = ComponentAccessor.mailServerManager
def mailServer = mailServerManager.defaultSMTPMailServer
if (mailServer && !MailFactory.settings.sendingDisabled) {
   def email = new Email('recipent@domain.com')
   email.setFrom(mailServer.defaultFrom)
   email.setSubject('your email subject')
   email.setMimeType('text/html')
   email.setBody('your email body')
   try {
      def mailItem = new SingleMailQueueItem(email)
      ComponentAccessor.mailQueue.addItem(mailItem)
      return "Mail sent"
   } catch ( MailException e){
      log.error e.message
      return "Failed to send"
   }
} else {
   return "Message not sent: no outgoing server or sending is disabled"
}

Suggest an answer

Log in or Sign up to answer