javamail access restriction error [message #496072] |
Sat, 07 November 2009 19:14  |
Eclipse User |
|
|
|
Hi,
I'm already programming for a year now in Eclipse. Today I started on a new project, this time one for myself. In the past I always could find the answers on one of the forums I check out.
I'm trying to initiate and build my own mailing program in JAVA. After looking around I found the package `javamail` from the SUN site. I also implemented the activation package, as required.
After downloading I placed them in JRE/lib folder, and added both to my project.
files:
- javamail 1.4.2.jar
- activation 1.1.1.jar
I found some code on the internet on how to send e-mail through JAVA.
import javax.mail.Session;
import javax.mail.Message;
import javax.mail.Transport;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.InternetAddress;
import java.util.Properties;
public class mail {
public static void main(String[] args) {
String from = "user@some-domain.com";
String to = "user@some-domain.com";
String subject = "Hi There...";
String text = "How are you?";
Properties properties = new Properties();
properties.put("mail.smtp.host", "smtp.some-domain.com");
properties.put("mail.smtp.port", "25");
Session session = Session.getDefaultInstance(properties, null);
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(subject);
message.setText(text);
Transport.send(message);
} catch (MessagingException e) {
e.printStackTrace();
}
}
The functionality of this I do understand completely, only there is a problem. This code gives a error, a Access Restriction error:
Access restriction: The method is not accessible due to restriction on required library D:\ ... \jre6\lib\javamail-1.4.2\mail.jar
Does someone know how I can solve this problem?
With regards,
farmer-duck
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04512 seconds