Paul Labis: This is a personal blog where everyone can read my experiences, ideas and thoughts about programming, latest gadgets and other information technology related topics, lifestyle and many other stuff I would like to share to the public.

Commons Email - Examples

I found another good apache tool for sending emails.
Its easy to use and has good documentation.
Below is an example of an easy way to sending an email.
It is explained properly on apache user guide page which is embedded on the bottom part of this article.

import org.apache.commons.mail.*;

// Create the attachment
EmailAttachment attachment = new EmailAttachment();
attachment.setDescription("Picture of John");

// Create the email message
MultiPartEmail email = new MultiPartEmail();
email.addTo("", "John Doe");
email.setFrom("", "Me");
email.setSubject("The picture");
email.setMsg("Here is the picture you wanted");

// add the attachment

// send the email