The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How send email with file

aas
Contributor
September 9, 2020

I have xls report file on the server and need to send this file in email in scriptrunner but don't understand how to add file in email 

def mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()
if (mailServer) {
Email email = new Email(to)
email.setCc(cc)
email.setSubject(subject)
email.setBody(body)
email.setMimeType("text/html")
mailServer.send(email)
log.debug("Mail sent to (${to}) and cc'd (${cc})")

I can add only String body. 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Aron Gombas _Midori_
Community Champion
September 9, 2020

I think the attachment goes to its separate "part". So check out the Email class' methods for how to work with "email parts".

aas
Contributor
September 9, 2020

I've checked out com.atlassian.email and haven't found anything about attachments

i searched here https://docs.atlassian.com/software/jira/docs/api/7.13.8/com/atlassian/jira/mail/Email.html