-
using java mail?
Hi all my Java program comples successfully. I also got the required Java Mail and Activation libraries
but when I run the program , I see the following error. Please help!
Exception in thread "main" java.lang.NoSuchMethodError: com.sun.mail.util.Socke
Fetcher.getSocket(Ljava/lang/String;ILjava/util/Properties;Ljava/lang/String;Z)
java/net/Socket;
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:3
0)
at javax.mail.Service.connect(Service.java:233)
at javax.mail.Service.connect(Service.java:134)
at javax.mail.Service.connect(Service.java:86)
at javax.mail.Transport.send0(Transport.java:162)
at javax.mail.Transport.send(Transport.java:80)
at FillinIndices.send(FillinIndices.java:306)
at FillinIndices.addIndices(FillinIndices.java:237)
at FillinIndices.main(FillinIndices.java:51)
Thanks! in advance
-
urgent! somebody please reply to below
-
hi
if you can show me your code then i think i can help you..
-
which version of java mail API you are using?
Is it running on Unix based system or on Microsoft?
-
Hi all
Thanks! for the help
Found the problem and resolved the issue.
I had the latest jars from the sun site
It was actually getting mixed up with other jars(that I used for my other program) that contained a version of this mail api or activation.jar. Once I removed that jar, it worked fine.
Pasted here is the code that I used to send out email :
public static void send(String smtpHost, int smtpPort, String from, String to, String subject, String content) throws AddressException, MessagingException
{
// Create a mail session
java.util.Properties props = new java.util.Properties();
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port", ""+smtpPort);
Session session = Session.getDefaultInstance(props, null);
// Construct the message
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
msg.setSubject(subject);
msg.setText(content);
// Send the message
Transport.send(msg);
}
Similar Threads
-
Replies: 2
Last Post: 08-31-2009, 12:50 AM
-
Replies: 9
Last Post: 09-19-2007, 05:58 AM
-
Replies: 1
Last Post: 05-13-2005, 06:46 AM
-
By JJ in forum Enterprise
Replies: 1
Last Post: 07-06-2000, 04:50 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks