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

Questions about IMailerService

Hello,

I'm extending TeamConcert V3 (server side) by implementing a precondition on the save workitem operation. My extension needs to send an email so I use IMailerService. Nevertheless, I have 2 questions about it and the content I need to put in my mail.

1/ I'm able to send an email, but is there a way to format it in HTML ? I tried this (which didn't worked) :

IMailerService mailer = getService(IMailerService.class);
mailer.sendMail(mailer.getDefaultSender(), myEmailAddress, "Mail title", "<h1>A header</h1>And the content, "");


2/ I have a reference to my workitem (both in old and new states) and I would like to get a link reference to put it in the mail. Il there a way to do it without building the URI by hands ?

Best Regards,
Sylvain Lequeux

0 votes



2 answers

Permanent link
the class com.ibm.team.workitem.service.internal.save.notify.ChangeEventMailNotifier

is the code that builds and send the standard RTC change notification messages. Net on the HTML format tho, is YOU format it, and put it into the mime structure to indicate HTML formatted.

you can get the source for the class and others by opening the Plugin perspective view, finding the com.ibm.team.workitem.service plugin, then right mouse button click, Import as Source Project.

the code that does the email processing and calls the mailer is in SendIndividualMails


if (recipient.prefersHtmlFormat() && htmlContent.length() > 0) {
MimeBodyPart plainBody= new MimeBodyPart();
plainBody.setText(hisContent, UTF_8);

MimeBodyPart htmlBody= new MimeBodyPart();
htmlBody.setText(hisHtmlContent, UTF_8);
htmlBody.setHeader("Content-type", "text/html; charset=" + UTF_8); //$NON-NLS-1$ //$NON-NLS-2$

MimeMultipart multipart= new MimeMultipart("alternative"); //$NON-NLS-1$
multipart.addBodyPart(plainBody);
multipart.addBodyPart(htmlBody);

mailer.sendMultipartMail(mailer.getDefaultSender(), recipient.getEmailAddress(), hisSubject, multipart, null);
} else {
mailer.sendMail(mailer.getDefaultSender(), recipient.getEmailAddress(), hisSubject, hisContent, null);
}


this class also builds the links and other workitem changes, so some code there would help u solve the URI question I think..

Sam

1 vote


Permanent link
Hi,

Thank you very much Sam. That was exactly what I was looking for.

Sylvain

0 votes

Comments

Hi Sylvain,

If possible, can you share this code, we are looking for the same feature.

Regards

Sachin Nairy

Hello,

Sam answered my first question with the code I used.
If you need something more, could you clarify what part of code is missing for you ?

Regards,
Sylvain

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,937

Question asked: Dec 05 '11, 9:07 a.m.

Question was seen: 7,906 times

Last updated: Aug 29 '13, 8:51 a.m.

Confirmation Cancel Confirm