When I compile a simple code that has the following 2 import statements:
import javax.mail.*
import javax.mail.internet.*
I get the following message:
package javax.mail does not exist
package javax.mail.internet does not exist
Why do I get this error?
Here is the code I have:
import javax.mail.*; import javax.mail.internet.*; import java.util.*; class tester { public static void main(String args[]) { Properties props = new Properties(); props.put("mail.smtp.com" , "smtp.gmail.com"); Session session = Session.getDefaultInstance( props , null); String to = "[email protected]"; String from = "[email protected]"; String subject = "Testing..."; Message msg = new MimeMessage(session); try { msg.setFrom(new InternetAddress(from)); msg.setRecipient(Message.RecipientType.TO , new InternetAddress(to)); msg.setSubject(subject); msg.setText("Working fine..!"); } catch(Exception exc) { } } }
activation packages contains the core classes of JavaMail API.
You need to download the JavaMail API, and put the relevant jar files in your classpath.
Download javax.mail.jar
and add it to your project using the following steps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With