Friday, July 31, 2009

A Groovier Eclipse experience

The much awaited plugin for Groovy is out for Eclipse. Read more..

I hope they have better support for Grails soon. For now, Netbeans 6.7 works like a charm :-)

Top 10 Web services issues

Here is a list of common concerns, questions and sources for debate that I come across when talking to architects and developers inside and outside of IBM® about Web services and -- to some degree -- SOA.
Read more here

Tuesday, July 28, 2009

SpringSource University Presents: Free Online Training

SpringSource University Presents: Free Online Training

SpringSource University is proud to present our first free online training. In this highly practical SpringSource course, trainer Jeff Brown will teach you how to develop aspects of Spring AOP. This training gives you both theoretical as well as practical knowledge of Spring AOP.

Download the training video

Wednesday, July 22, 2009

Send email through Java

import java.util.ArrayList;
import java.util.Properties;

import javax.mail.Address;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMail {

private static String exchangeServer = "400exch1";
private static String subject;
private static String fromAddress;
private static String footer;

private static String getSubject() {
return subject;

private static void setSubject(String aSubject) {
subject = aSubject;

private static String getFromAddress() {
return fromAddress;

private static void setFromAddress(String aFromAddress) {
fromAddress = aFromAddress;

private static String getFooter() {
return footer;

private static void setFooter(String aFooter) {
footer = aFooter;

public SendMail(String subj, String fromAdd, String footerMsg) {
subject = subj;
fromAddress = fromAdd;
footer = footerMsg;

private static void send(ArrayList to, String from, String host, String message) {
if (to == null || from == null || message == null || host == null) {
Properties props = System.getProperties();
props.put("", host);
Session session = Session.getDefaultInstance(props, null);
if (session == null) {
MimeMessage mm = new MimeMessage(session);
try {
Address addresses[] = new Address[to.size()];
for (int i = 0; i <> 1) {
for (int j = 0; j < addresses.length - 1; j++) { mm.addRecipients(javax.mail.Message.RecipientType.CC, addresses[j + 1].toString()); } } mm.setSubject(getSubject()); mm.setContent((new StringBuilder()).append(message).append( "

\n\n\n** Do not reply to this message ***
} catch (AddressException ex) {
} catch (MessagingException ex) {

public void sendEmail(String message, ArrayList emailList) {
if (message == null) {
} else {
send(emailList, getFromAddress(), exchangeServer, message);


Constructor Detail


public SendMail(java.lang.String subj,

                java.lang.String fromAdd,

                java.lang.String footerMsg)


subj - Subject of the email     (String)

fromAdd - From Address   (String)

footerMsg - Set Custom footer message - optional (String)


Method Detail


public void sendAlert(java.lang.String message,

                      java.util.ArrayList emailList)


message - Message body to be sent in the email- Text or HTML

The Html Body could contain image with a valid link

emailList - Array list of the email addresses the email to be sent.

For example to send to email -

To send to Email Groups just add the email group to the array list

For example to send email to CIM Group add "#CIM" to the array list.


Sample Code

SendMail sm = new SendMail("Test Email", "Anonymous", "Please do not reply to this email");

ArrayList<String> addressList = new ArrayList<String>();


sm.sendAlert("This is a Test Message", addressList);