It's all about the answers!

Ask a question

Programmatically sending emails using IMailerService


Raza Abbas Syed (164) | asked Apr 01 '09, 12:23 a.m.
I've been trying to send emails programmatically using IMailerService but its not working for some reason. The email notification is enabled and the jazz server is sending emails. I verified that by sending out team invitations, so the smtp server appears to be in order.

However, when I try to send an email programmatically through a simple snippet of code, it does not work. I tried writing the exception (if any) to a file, but turns out ... it never throws an exception either, since I cant find the file on the server. Here's the code:


try {
IMailerService mailerService = getService(IMailerService.class);
mailerService.sendMail(mailerService.getDefaultSender(), "<my-email-here>", "Jazz Test Email", "Test", "<some-cc-address-here>");
} catch (MessagingException e) {
// write to a file
try
{
java.io.FileWriter writer = new java.io.FileWriter("myfile.txt");
java.io.BufferedWriter out = new java.io.BufferedWriter(writer);
out.write(e.getMessage());
out.close();
writer.close();
}
catch (IOException ex)
{
ex.printStackTrace();
}
}


Thanks!

One answer



permanent link
Gaston Williams (81126) | answered Apr 22 '09, 1:44 p.m.
I've been trying to send emails programmatically using IMailerService but its not working for some reason. The email notification is enabled and the jazz server is sending emails. I verified that by sending out team invitations, so the smtp server appears to be in order.
Thanks!


You have to turn email on in your local workspace. A co-worker sent me these instructions below:

By default, email is not enabled in the RTC development test server (Jetty/Derby) environment. These instructions show how to enable email:


1) Open your server (OSGi Framework) launch configuration. Go to the Arguments tab. Add the text for a new parameter below... make sure you do NOT add any newline characters... just use spaces to separate each VM argument.

-Dcom.ibm.team.server.configURL=file:///{$target_home}/../../server/teamserver.properties

2) Open <RTC>\jazz\server\teamserver.properties in a text editor:

3) Add the following lines to the bottom of the file:

com.ibm.team.repository.notification.mail.enabled=true
com.ibm.team.repository.notification.mail.from_name=jazzdev@us.ibm.com
com.ibm.team.repository.notification.mail.from=jazzdev@us.ibm.com
com.ibm.team.repository.notification.mail.smtp.server=relay.us.ibm.com
com.ibm.team.repository.notification.mail.reply=noreply-jazzdev@us.ibm.com


Good luck!

Your answer


Register or 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.