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) :
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
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
2 answers
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
this class also builds the links and other workitem changes, so some code there would help u solve the URI question I think..
Sam
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