Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes



One answer

Permanent link
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();
plainBody.setText(getPlainTextContent(), UTF_8);

MimeBodyPart htmlBody = new MimeBodyPart();
htmlBody.setText(getHtmlContent(), UTF_8);
htmlBody.setHeader("Content-type", "text/html; charset=" + UTF_8);

MimeMultipart multipart= new MimeMultipart("");
multipart.addBodyPart(plainBody);
multipart.addBodyPart(htmlBody);

mailer.sendMultipartMail(mailer.getDefaultSender(), getEmailAddress(), "My Email Subject", multipart, null);

0 votes

Comments

 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

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

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,940

Question asked: Sep 04 '18, 12:33 p.m.

Question was seen: 1,377 times

Last updated: Sep 05 '18, 4:04 p.m.

Confirmation Cancel Confirm