Forums

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

Mail handler isn't including message body in tickets

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2023

Hi Team,

We are currently investigating why the email body of an external sender did not appear in the incoming email handler tickets. Attached is a screenshot of the email body. The ticket description only includes the message: "[Created via e-mail received from Microsoft Azure <azure-noreply@microsoft.com>]". Our account's sent emails are successfully adding the email body to the tickets. We suspect that there may be an issue with the email body's formatting.

Could you please suggest us?

PIM.PNG

2 answers

0 votes
Kseniia Trushnikova
Community Champion
July 14, 2023

Hi @Lakshmi CH,

Your issue looks similar to this: https://confluence.atlassian.com/jirakb/jira-created-issue-from-e-mail-has-no-description-744526382.html

As for this:

Our account's sent emails are successfully adding the email body to the tickets. We suspect that there may be an issue with the email body's formatting.

Do these emails have the same body as Microsoft Azure's emails do? Can you try to forward Microsoft Azure's emails from your mailbox and check if the created ticket has the correct Description?

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 14, 2023

Hi @Lakshmi CH

Could you please share the mail handler configuration that you are currently using? I am requesting for this so I can review it and provide some feedback and suggest a better solution.

Thank you and Kind regards,

Ram

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 14, 2023

Hi, @Ram Kumar Aravindakshan _Adaptavist_.

PFA screenshots for your reference.

i1.PNG

i2.PNG

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 14, 2023

Hi @Lakshmi CH ,

This is your outgoing mail configuration.

This is not what I requested.

I need to see your mail handler configuration and code.

Thank you and Kind regards,

Ram

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 14, 2023

Sorry @Ram Kumar Aravindakshan _Adaptavist_, Where should I check this mail handler configuration and code?

Susan Sako
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!
June 14, 2023

Hi @Ram Kumar Aravindakshan _Adaptavist_ -- Lakshmi provided the incoming mail configuration and mail handler, but perhaps you are looking for more details of the handler config? If this isn't what you are looking for please describe where to gather it.MailHandlerPg2.png

MailHandlerEditPg1.pngBasicMailHandler.png

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 14, 2023

Hi @Susan Sako / @Lakshmi CH 

Thank you for getting back and providing the screenshots.

From the latest screenshots you shared, this doesn't appear to be ScriptRunner's Mail Handler.

You are instead using the Create a new issue from each email handler.

If you want to include the message body via ScriptRunner's Mail Handler, you will need to change your mail handler configuration to:-

mail_handler.png

Once you have selected ScriptRunner's Mail Handler, you will need to add some conditions to the code like the example below:-

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.util.JiraHome
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.service.services.file.FileService
import com.atlassian.jira.service.util.ServiceUtils
import com.atlassian.jira.service.util.handler.MessageUserProcessor
import com.atlassian.mail.MailUtils
import org.apache.commons.io.FileUtils

def userManager = ComponentAccessor.userManager
def projectManager = ComponentAccessor.projectManager
def issueManager = ComponentAccessor.issueManager
def issueFactory = ComponentAccessor.issueFactory
def commentManager = ComponentAccessor.commentManager
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)
def jiraHome = ComponentAccessor.getComponent(JiraHome)

def subject = message.subject as String
def issue = ServiceUtils.findIssueObjectInString(subject) as MutableIssue

if (issue) {
return
}

def user = userManager.getUserByName('admin')
def reporter1 = messageUserProcessor.getAuthorFromSender(message) ?: user
def project = projectManager.getProjectObjByKey('MOCK')

def issueObject = issueFactory.issue
issueObject.setProjectObject(project)
issueObject.setSummary(subject)
issueObject.setDescription(MailUtils.getBody(message))
issueObject.setIssueTypeId(project.issueTypes.find { it.name == 'Bug' }.id)
issueObject.setReporter(reporter1)
issue = messageHandlerContext.createIssue(user, issueObject) as MutableIssue

def attachments = MailUtils.getAttachments(message)

def issueDescription = new StringBuilder(issue.description).append('\n')

def destination = new File(jiraHome.home, FileService.MAIL_DIR).canonicalFile

attachments.each {
def file = FileUtils.getFile(it.filename) as File
messageHandlerContext.createAttachment(file, it.filename, it.contentType, user, issue)
}
FileUtils.forceDelete(destination.listFiles().first())


issue.setDescription(issueDescription.toString())
commentManager.create(issue, user, 'This is a sample', true)

issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH,false)

Please note that the working sample code above is not 100% exact to your environment. Hence, you will need to modify it accordingly.

I hope this helps to solve your question. :-)

Thank you and  Kind regards,

Ram

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 22, 2023

Hi @Lakshmi CH / @Susan Sako

Has your question been answered?

If yes, please accept the answer.

Thank you and Kind regards,

Ram

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 22, 2023

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

I don't want to try the process as it is not a straightforward solution for all users; it only works who have that addon. There seems to be an issue with the formatting that arises from Microsoft Azure.

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 22, 2023

Hi @Lakshmi CH 

Thanks for getting back.

I have removed the ScriptRunner tag from this question as it is pretty misleading, which is the main reason I provided that solution is because I assumed you were using ScriptRunner.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer