Showing posts with label the. Show all posts
Showing posts with label the. Show all posts

Monday, August 1, 2011

Sending Emails with or without Attachments Using Java the Simplest and Easiest Way

Hello Fellaws


You must have searched a lot for sending mails with/without attachments using Java.


Some succeeded (Congrats Fellaws :P ) and other's didn't (No Problem this Post will help you).


But, I am sure this post will make your life easier, if you are plaining to develop a code which includes Mail functionality with or without attachments.


In 2 lines you can mail to any one :)


Before we look at the code here is the API's zip file which you have to import in your project
Download APIs Here


This zip file contains 2 APIs
  1. RavMail.jar  [ Containing the core code to send emails with or without attachments ] 
  2. RavMailSupport.jar [Support JAR file ]
Let me provide you a simple code demo which will make easy for you all to use this API in your projects


Steps are as follows
  • Import these JAR files in your project. I am using NetBeans to develop my demo code. Steps are provided to import APIs in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above 2 JAR files
    • You are done with importing API in your project


  • Now Comes the coding section
    • If you want to mail only text i.e. without any attachments, then below is the code to send emails.



    • If you want to send an email with attachment then follow the below code 


Thats it Congratulations using these 2 line code you can email to anyone :) with your own code.

Thats it for this Post.

Take Care

Peace


For Any Query mail me: ravjot.singh.28@gmail.com