I am using java mail api to send the mail but stuck with the following error ..
no suitable method found for getInstance(java.util,Properties,java.net.Authenticator)
And here is my code code snippet in java..
Authenticator auth = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password.toCharArray());
}
};
Session session = Session.getInstance(properties, auth);
I am getting the mentioned error on following line..
Session session = Session.getInstance(properties, auth);
Please help me . Thanks in advance..
The problem is that you've imported java.net.Authenticator
instead of javax.mail.Authenticator
. Look at the types specified in the error message, then look at the parameter types in the documentation for Session.getInstance
.
See more on this question at Stackoverflow