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

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

Suggest an answer

Log in or Sign up to answer