Forums

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

Custom script to send emails to email id's from a csv file.

manjupriya_t
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 11, 2020

Hi,

I'm looking for a custom script to send emails by parsing values in a csv file, when a state transition occurs.

We have a listener to listen status changed events.

I have written a custom script,  but i'm struck to read values from csv and use it as email address. Please help me here.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.mail.Email
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer
import com.atlassian.jira.user.ApplicationUser

def sendEmail(String emailAddr, String subject, String body) {
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()
if (mailServer) {
Email email = new Email(emailAddr)
email.setSubject(subject)
email.setBody(body)
mailServer.send(email)
log.debug("Mail sent")
} else {
log.warn("..")
}
}

 

 

Thanks

1 answer

0 votes
A_Lakshmi Durga February 23, 2022

Hi @manjupriya_t ,

 

Did you find the solution for this. If yes, please share me the solution.

 

Thanks,

Lakshmi

Suggest an answer

Log in or Sign up to answer