Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Programming in Groovy



Recently I got an opportunity to work on Groovy & Grails in my 10 years companion with Java. It is very interesting to see the result in few lines..

To write a logic to send an email in Java, we all know how may lines of code, exception handling bla, bla.. Come to groovy, it is done in few lines.

//SendEmail.groovy
//Sending an email notification
new AntBuilder().mail(mailhost:"mail.yourserver.com", messagemimetype:'text/html',
          subject:"Test Subject"){
    from(address:"you@yourserver.com")
    to(address:"you@yourserver.com")
    message("Test Message")
}

Have fun guys..
-YA