i have no problem while i complile the program.
this is my source code ......
[code=java]
import javax.mail.*;
import javax.mail.inte rnet.*;
import java.util.*;
class MailTest1
{
public static void main(String args[])
{
try
{
if(args.length == 0)
{
throw new Exception("Insu fficient arguments ....");
}
String smtpServer=args[0];
String to=args[1];
String from=args[2];
String subject=args[3];
String body=args[4];
send(smtpServer , to, from, subject, body);
}
catch (Exception ex)
{
System.out.prin tln("Exception in main: " + ex.getMessage() );
}
}
public static void send(String smtpServer, String to, String from
, String subject, String body)
{
try
{
Properties props = System.getPrope rties();
// -- Attaching to default Session, or we could start
props.put("mail .smtp.host", smtpServer);
Session session = Session.getDefa ultInstance(pro ps, nu
// -- Create a new message --
Message msg = new MimeMessage(ses sion);
// -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress (from));
msg.setRecipien ts(Message.Reci pientType.TO,
InternetAddress .parse(to, false));
// -- We could include CC recipients too --
// if (cc != null)
// msg.setRecipien ts(Message.Reci pientType.CC
// ,InternetAddres s.parse(cc, false));
// -- Set the subject and body text --
msg.setSubject( subject);
msg.setText(bod y);
// -- Set some other header information --
msg.setHeader(" X-Mailer", "LOTONtechEmail ");
msg.setSentDate (new Date());
// -- Send the message --
Transport.send( msg);
System.out.prin tln("Message sent OK.");
}
catch (Exception ex)
{
System.out.prin tln("Exception in send: " + ex.getMessage() );
}
}
}
[/code]
but when i run the program then i get an error ......
Exception in thread "main" java.lang.NoCla ssDefFoundError : javax/mail/Message
plz help...
it's urgent
kind regards,
dmjpro.
this is my source code ......
[code=java]
import javax.mail.*;
import javax.mail.inte rnet.*;
import java.util.*;
class MailTest1
{
public static void main(String args[])
{
try
{
if(args.length == 0)
{
throw new Exception("Insu fficient arguments ....");
}
String smtpServer=args[0];
String to=args[1];
String from=args[2];
String subject=args[3];
String body=args[4];
send(smtpServer , to, from, subject, body);
}
catch (Exception ex)
{
System.out.prin tln("Exception in main: " + ex.getMessage() );
}
}
public static void send(String smtpServer, String to, String from
, String subject, String body)
{
try
{
Properties props = System.getPrope rties();
// -- Attaching to default Session, or we could start
props.put("mail .smtp.host", smtpServer);
Session session = Session.getDefa ultInstance(pro ps, nu
// -- Create a new message --
Message msg = new MimeMessage(ses sion);
// -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress (from));
msg.setRecipien ts(Message.Reci pientType.TO,
InternetAddress .parse(to, false));
// -- We could include CC recipients too --
// if (cc != null)
// msg.setRecipien ts(Message.Reci pientType.CC
// ,InternetAddres s.parse(cc, false));
// -- Set the subject and body text --
msg.setSubject( subject);
msg.setText(bod y);
// -- Set some other header information --
msg.setHeader(" X-Mailer", "LOTONtechEmail ");
msg.setSentDate (new Date());
// -- Send the message --
Transport.send( msg);
System.out.prin tln("Message sent OK.");
}
catch (Exception ex)
{
System.out.prin tln("Exception in send: " + ex.getMessage() );
}
}
}
[/code]
but when i run the program then i get an error ......
Exception in thread "main" java.lang.NoCla ssDefFoundError : javax/mail/Message
plz help...
it's urgent
kind regards,
dmjpro.
Comment