Using JavaMail API to send an email in JAVA

We can send mail through JavaMail Api through java code.I have read somewhere and thought of sharing with everyone.
For using this code you need to JavaMail Api.

//get mail session

Properties props = new Properties();
Session session = session.getDefaultInstance(props);

// create the messge.
MimeMessage message = new MimeMessage(session);
message.setSubject("Vinay first Mail");
Message.setText("Vinay mail text ");

//address the message
InternetAddress addfrm = new InternetAddress("[email protected]");
InternetAddress addto = new InternetAddress("[email protected]");

//send message


Send email in text and html format Text and HTML format

pimp it


I am an Oracle ACE in Oracle ADF/Webcenter. Sr Java Consultant-working on Java/J2EE/Oracle ADF/Webcenter Portal/ content and Hibernate for several years. I'm an active member of the OTN JDeveloper/Webcenter forum. Passionate about learning new technologies. I am here to share my knowledge. Give your views and suggestion on [email protected] .

More Posts - Website

Follow Me:
TwitterLinkedInGoogle PlusYouTube