hello can anyone please give me solution to this ,
i have below information which send in mail using listener but ,
i want to send mail in below format,
Hi @Sneha Gole,
For your requirement, if you are using the Send custom email listener, you will need to send the email using the HTML format.
To do so in the listener, you will need to set the Email format to HTML and format the Email template using the HTML parameters as shown in the image below:-
If possible, could you please share your listener configuration?
Thank you and Kind Regards,
Ram
Hii @Ram Kumar Aravindakshan _Adaptavist_ thank you for your response .
i am using below listener
and sending mail using ,
MailServerManager mailServerManager = ComponentAccessor.getMailServerManager()
SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer()
Email email = new Email(issue.getReporter().getEmailAddress())
email.setMimeType("text/html")
email.setTo(to)
def toCC = ""
cc.each
{
toCC = it.toString() + "," + toCC
}
log.warn toCC
// email.setCc(toCC)
// email.setSubject(issue.summary)
// email.setBody(html)
// mailServer.send(email)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sneha Gole
If you are using the Custom Listener, you can try something like this:-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.mail.Email
def issue = event.issue
def mailServerManager = ComponentAccessor.mailServerManager
def mailServer = mailServerManager.defaultSMTPMailServer
def reporter = issue.reporter
def emailAddress = reporter.emailAddress
def subject = "This is a test mail"
body = """
<html>
<body>
<h1>Subject:</h1>
<h3>Sample Content For Testing Purposes</h3>
</body>
</html>
"""
def email = new Email(emailAddress.toString())
email.setSubject(subject)
email.setBody(body)
email.setMimeType("text/html")
def threadClassLoader = Thread.currentThread().contextClassLoader
Thread.currentThread().contextClassLoader = mailServer.class.classLoader
mailServer.send(email)
Thread.currentThread().contextClassLoader = threadClassLoader
Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.
Basically, the text that you want to format should be added to the HTML body, i.e.
body = """
<html>
<body>
<h1>Subject:</h1>
<h3>Sample Content For Testing Purposes</h3>
</body>
</html>
"""
You will need to trim the text if you want to remove the ending portion of the text. You can use the replace option in the String.
I hope this helps to solve your question. :)
Thank you and Kind Regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.