Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,299,295
Community Members
 
Community Events
165
Community Groups

how to send custom attachment from my directory in email

hi

I want to send custom attachment in mail that not attached on issue

I make it on jira file directory in address (/sharedhome/data/attachment-test/447788) 

for example 447788 is atatchment id in this directory and file name is viop.pdf

my script for send email is below and work right in custom script:

 

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

def subject = "Insert text here for ${issue.key}"
def body = "Hi ${issue.assignee.displayName} \n\nNow that XXXXX has been released, please complete XXXXX for the following issue: https://XXXXXXX/${issue.key} - ${issue.summary}. \n\n"
def emailAddr = issue.getAssignee().getEmailAddress()

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)

} else {
// log this error
}
}

sendEmail (emailAddr, subject, body)

 

please help me to add attachment in this script

thanks regard

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

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