Home » Example of receiving attachment with email in Java

Example of receiving attachment with email in Java

by Online Tutorials Library

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 ReadAttachment.java
run by c:> java ReadAttachment

You may also like