Send work item id as a hyperlink in mail
Hi All,
Scenario is that I have developed sever side plugin to send mail to team members on work item creation. Mail send to all team members successfully.but in mail description I want to work item id as hyperlink instead of separate work item hyperlink
Is it possible ?please provide suggestions on same
Clm server 6.0.5
|
One answer
David Lafreniere (4.8k●7)
| answered Sep 05 '18, 11:21 a.m.
FORUM MODERATOR / JAZZ DEVELOPER edited Sep 05 '18, 3:46 p.m.
You'll need to set the header "Content-type" to "text/html", this would then allow you to use the normal HTML hyperlink <a> tags for links (and other formatting such as bold, etc.). For non-html emails, you could just stick the URL at the end in brackets. ex: "Work Item 1234 (<url>)"
To use HTML in emails you need to create a javax.mail.internet.MimeBodyPart and add this to a javax.mail.internet.MimeMultipart.
See the following code:
IMailerService mailer = getMailerService(); MimeBodyPart plainBody= new MimeBodyPart();
Comments
Rohini Kumar
commented Sep 05 '18, 3:31 p.m.
What is the type of message? Can I pass text on there? And for Multipart IMailerServer is required?or can I use mailService.sendMultipartMail() ?I am bit confusing
Please provide the suggestions on same
Thank you
David Lafreniere
commented Sep 05 '18, 3:46 p.m.
| edited Sep 05 '18, 4:04 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
By "text" do you mean a String? If so, yes it does.
You have to use: mailerService .sendMultipartMail(...)
Here is a simpler version which I think answers the questions.
IMailerService mailerService = getMailerService();
MimeBodyPart htmlBody= new MimeBodyPart();
htmlBody.setText("This is my email content. This is in <b>bold</b>", UTF_8);
htmlBody.setHeader("Content-type", "text/html; charset=" + UTF_8);
MimeMultipart multipart = new MimeMultipart("");
multipart.addBodyPart(htmlBody);
mailerService .sendMultipartMail(mailerService .getDefaultSender(), getEmailAddress(), "My Email Subject", multipart, null);
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.