Hello,
is it possible to remove the email footer or signature within a script runner mailhandler? If so, how would you achieve this feature?
Yours Christoph
Hi @[deleted]
I tried the same with the email history and wanted to cut that off. However, this is had to be done by some string processing and looking for keywords like "From: " and it is not the best working solution. But if the footer and signature is always looking similar you can try to search the mail body for keywords and cut it off.
What I also did was to remove the small icons from the signatures (<5kb) from the issues attachments. Usually you only want to have real attachments form an email in the issue and not those small icons. I did that by removing them directly from the issue in the mail handler script.
Hi @Jonas Moehringer - ij-solutions ,
have you got some code snippets? I have no idea how to remove such things. Lookd up some RegEx but have also not a real idea of how this might works.
Thanks
sure, here is an example of how the remove everything from the body starting from string "From: ":
if(body.toString().indexOf("From: ")!=-1){ if(body.toString().indexOf("From: ")!=0){ body = body.toString().substring(0, body.toString().indexOf("From: ")) }}
It also considers that "From: " can't be at the beginning of the body because then nothing would be left of the body.
Afterwards, this body can be set as description. I am not an expert with regEx but there might be some nice solutions with regEx as well to cover more different email contents.
Hello @Jonas Moehringer - ij-solutions
thanks for your example. I've already implemented another workaround where I used the split() method to cut the mail in 2 parts and only used the first one in my description.
issueObject.setDescription(MailUtils.getBody(message).split("codeword")[0])
Since our signature is static this works out for me.
Just one more question, do you have any idea / solution how to add the mail also to the attachment section of an issue so people can watch the original mail or store it?
Thanks in advance
I have posted my workaround here
https://jira.atlassian.com/browse/JRACLOUD-15129?focusedId=3429016&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-3429016
It looks like you're new here. Sign in or register to get started.