0
I’m trying to use the API Commons-Email as an alternative to the known JavaMail
to send emails in Java but a problem is occurring. The following is being launched Exception
:
Exception in thread "main" java.lang.Noclassdeffounderror: javax/mail/Message at Main.main(Main.java:6)
The problem occurs on line 6 when I try to instantiate a class object SimpleEmail
. Just follow my code:
import org.apache.commons.mail.SimpleEmail;
public class Main {
public static void main(String[] args) {
try {
SimpleEmail email = new SimpleEmail(); // ops?! Aqui é lançada a Exception
email.setHostName("mail.foo.com");
email.setFrom("[email protected]", "rnxn") // remetente
.addTo("[email protected]", "Sr. Foo") // destinatário
.setMsg("Exception sendo lançada ao utilizar a API Commons-email") // corpo do email
.setSubject("StackOverflow"); // título
email.send(); // envio
} catch(Exception e){
System.out.println(e.getMessage());
}
}
}
I have properly imported all files .jar that came in the download. Any solution for the treatment of this problem?
that is problems of Imports at least with me that error has always appeared because of it, sometimes some of the Lib’s is even correct but is in a different version than the one that is requested...
– jsantos1991
The problem is related to the
import
but it wasn’t because of the versions. Still I appreciate your comment.– Renan Gomes
Ta missing jars ai... He’s talking q did not find the Message class of javax.mail
– yehiaazanki