Javatpoint Logo
Javatpoint Logo

Receiving email with attachment in Java

As we receive the email, we can receive the attachment also by using Multipart and BodyPart classes found in JavaMail API.

For better understanding of this example, learn the steps of sending email using JavaMail API first.

For receiving or sending the email using JavaMail API, you need to load the two jar files:

  • mail.jar
  • activation.jar
download these jar files (or) go to the Oracle site to download the latest version.

Example of receiving email with attachment in Java

Load the jar file c:\> set classpath=mail.jar;activation.jar;.;
compile the source file c:\> javac
run by c:\> java ReadAttachment

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA