package javax.mail and javax.mail.internet do not exist
Solution 1:
You need to download the JavaMail API, and put the relevant jar files in your classpath.
Solution 2:
Download javax.mail.jar
and add it to your project using the following steps:
- Extract the mail.jar file
- Right click the project node (JavaMail), click Properties to change properties of the project
- Now go to Libraries Tab
- Click on Add JAR/Folder Button. A window opens up.
- Browse to the location where you have unzipped your Mail.jar
- Press ok
- Compile your program to check whether the JAR files have been successfully included
Solution 3:
If using maven, just add to your pom.xml:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.5.0-b01</version>
</dependency>
Of course, you need to check the current version.
Solution 4:
You need the javax.mail.jar
library.
Download it from the Java EE JavaMail GitHub page and add it to your IntelliJ project:
- Download
javax.mail.jar
- Navigate to
File > Project Structure...
- Go to the Libraries tab
- Click on the
+
button (Add New Project Library) - Browse to the
javax.mail.jar
file - Click OK to apply the changes
Solution 5:
For anyone still looking to use the aforementioned IMAP library but need to use gradle, simply add this line to your modules gradle file (not the main gradle file)
compile group: 'javax.mail', name: 'mail', version: '1.4.1'
The links to download the .jar file were dead for me, so had to go with an alternate route.
Hope this helps :)