Hi experts,
please can someone help my by the following error:
<b>NoSuchProviderException: No provider for SMTP</b>
public class SendJavaMail {
private static String status;
private static String status_transport;
public static String generateMail() {
Properties props = new Properties();
props.setProperty("mail.smtp.host", "ServerName");
props.setProperty("mail.smtp.auth" , "false");
Session session = Session.getDefaultInstance(props);
try {
MimeMessage mMeassage = new MimeMessage(session);
mMeassage.setSubject("Subject");
mMeassage.setText("Hello");
InternetAddress fromAddress =
new InternetAddress("[email protected]");
InternetAddress toAddress =
new InternetAddress("[email protected]");
mMeassage.setFrom(fromAddress);
mMeassage.setRecipient(Message.RecipientType.TO,
toAddress);
Transport transport = session.getTransport("SMTP");
status_transport = String.valueOf(transport);
<b>transport.connect("ServerName", "", "");</b>
transport.send(mMeassage);
transport.close();
status = "Mail verschickt";
} catch (MessagingException e) {
status = e.getMessage();
try{
<b>Transport transport = session.getTransport("SMTP");</b>
status_transport = String.valueOf(transport);
}
catch(NoSuchProviderException pe){
status_transport
= "NoSuchProviderException: "+pe.getMessage();
}
}
status = "Status Transport: "+status_transport+"
Status: "+status;
return status;
}
}
I think transport.connect("ServerName", "", "") is not correct and
Transport transport = session.getTransport("SMTP") I get the error:
NoSuchProviderException
Have anyone an idea? Thanks in advanve!
If i change:
<b>transport = session.getTransport("smtp");</b>
I get the error:
java.lang.NoSuchMethodError: com.sun.activation.registries.MailcapFile.getMailcapList(Ljava/lang/String;)Ljava/util/Map;
Message was edited by:
SAP User
Request clarification before answering.
Hi,
include mail.jar,activation.jar,smtp.jar and other mail jar files in your classpath .
See that only one version of this jar's added to the classpath.
Answer if usefull...... reward with points.
Thanks
Ritu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.