Hi everyone,
is here someone, who fight with JIRA API for sending emails? I have problems with attachments, they're always as in-line. Thunderbird have problem with show it, on gmail or apple mail I can see them, but just below message body.
Here some code: (I use jython...)
from com.atlassian.jira.component import ComponentAccessor
from com.atlassian.jira.mail import Email
from com.atlassian.jira.mail.builder import EmailBuilder
from com.atlassian.jira.mail.util import MailAttachments
from com.atlassian.jira.notification import NotificationRecipient
ap = ComponentAccessor.getApplicationProperties()
authenticationContext = ComponentAccessor.getJiraAuthenticationContext()
currentUser = authenticationContext.getLoggedInUser()
mq = ComponentAccessor.getMailQueue()
am = ComponentAccessor.getAttachmentManager()
recipient = NotificationRecipient(currentUser)
email = Email(currentUser.getEmailAddress())
lm = ComponentAccessor.getLocaleManager()
issuekey = issue.getKey()
issueUrl = ap.getString("jira.baseurl") + "/browse/" + issuekey
subject = "Update in " + issue.getKey()
body = """Here is update from <a href="%(issueUrl)s">%(issuekey)s</a>.
Below you find attachments.
\n
""" % { "issuekey": issuekey, "issueUrl": issueUrl }
attachments = issue.getAttachments()
emailAttachments = []
for attachment in attachments:
emailAttachments.append(MailAttachments.newMailAttachmentByStreamingFromAttachmentManager(attachment,am).buildBodyPart())
#newEmail = EmailBuilder(email,NotificationRecipient(currentUser)).withBody(body).withSubject(subject).addAttachments(emailAttachments)
newEmail = EmailBuilder(email,"text/html",lm.getLocaleFor(currentUser)).withBody(body).withSubject(subject).addAttachments(emailAttachments)
queueItem = newEmail.renderNowAsQueueItem()
well, i found resolution :P
i = 0
while i < len(attachments):
emailAttachments[i].setDisposition("attachment")
emailAttachments[i].setFileName(attachments[i].getFilename())
i += 1
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.