Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sending email is not working in jdk1.3  RSS feed

 
Rajesh kumar ananthula
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

my program is this

import java.util.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.Session;
import javax.mail.event.*;
import javax.mail.internet.*;
public class mail
{
final static String mailhost="webmail.arsin.com";
public mail()
{
}
public static boolean sendMail(String fromUser,String toUser,String subject,String body) throws Exception
{
System.out.println("Entered the mail block of SendMail");
System.out.println(""+fromUser+ " "+toUser+ " "+subject+ " "+body);
Properties properties = new Properties();
properties.put("mail.smtp.host",mailhost);
properties.put("mail.from",fromUser);
Session sessionMail = Session.getInstance(properties,null);
Message message = new MimeMessage(sessionMail);
InternetAddress[] address = { new InternetAddress(toUser)};
message.setRecipients(Message.RecipientType.TO,address);
message.setFrom(new InternetAddress(fromUser));
message.setSubject(subject);
message.setContent(body,"text/plain");
message.setSentDate(new Date()); //Code added by Swapna to add the current date in the mail
Transport transport = sessionMail.getTransport(address[0]);
System.out.println("after session.getTransport(address[0]);.......");
transport.connect();
System.out.println("after tranport connected.....");
transport.sendMessage(message,address);
System.out.println("after transport object is created....");
System.out.println("Your mail has been sent...");
return true;
}
public static void main(String args[] )
{
final String fromUser="rananthula@arsin.com";
final String toUser="skaturi@arsin.com";
final String subject="Some Subject to verify the email being sent or not";
final String body="This is a test message to verify the email";
mail m=new mail();
try
{
boolean mailsent = m.sendMail(fromUser,toUser,subject,body);
System.out.println(mailsent);
}
catch(Exception e)
{
System.out.println("Error sending the mail is " + e);
}
}
}

It's not working in jdk1.3

The same program is working under jdk5.0

please let me know if anybody knows the solution.
 
Rajesh kumar ananthula
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey its urgent..please reply fast
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Define 'not working'. Does it not compile - if so post the exact error messages with an indication of what line they refer to. Does it not do what you want it to do - if so tell us what it is doing and what it should be doing.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rajesh kumar ananthula:
hey its urgent..please reply fast


Also read this
 
Rajesh kumar ananthula
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's compiled. I have attached in class path mail.jar and activation.jar. when I am runinng this program i got the error message in JDK1.3 is

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream
at javax.mail.Session.loadProvidersFromStream(Session.java:828)
at javax.mail.Session.loadProviders(Session.java:746)
at javax.mail.Session.<init>(Session.java:81)
at javax.mail.Session.getInstance(Session.java:103)
at mail.sendMail(mail.java:30)
at mail.main(mail.java:59)
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well according to this post, that class is in mail.jar, so it would seem to be a problem with your classpath.
 
Rajesh kumar ananthula
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is a class in mail.jar. I worked with same as in jdk1.5. So i think I placed correct classpath. Is there any different mail.jar files for jdk1.5 and jdk1.3.
 
Rajesh kumar ananthula
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please reply ASAP
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once again I suggest you read this.
You should also read this. It took me less than a minute searching on the Sun Java website to find what was possibly causing your problem.
[ March 26, 2008: Message edited by: Joanne Neal ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!