i have no problem while i complile the program.
this is my source code ...... -
import javax.mail.*;
-
import javax.mail.internet.*;
-
import java.util.*;
-
-
class MailTest1
-
{
-
public static void main(String args[])
-
{
-
try
-
{
-
if(args.length == 0)
-
{
-
throw new Exception("Insufficient 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.println("Exception in main: " + ex.getMessage());
-
}
-
}
-
public static void send(String smtpServer, String to, String from
-
, String subject, String body)
-
{
-
try
-
{
-
Properties props = System.getProperties();
-
// -- Attaching to default Session, or we could start
-
props.put("mail.smtp.host", smtpServer);
-
Session session = Session.getDefaultInstance(props, nu
-
// -- Create a new message --
-
Message msg = new MimeMessage(session);
-
// -- Set the FROM and TO fields --
-
msg.setFrom(new InternetAddress(from));
-
msg.setRecipients(Message.RecipientType.TO,
-
InternetAddress.parse(to, false));
-
// -- We could include CC recipients too --
-
// if (cc != null)
-
// msg.setRecipients(Message.RecipientType.CC
-
// ,InternetAddress.parse(cc, false));
-
// -- Set the subject and body text --
-
msg.setSubject(subject);
-
msg.setText(body);
-
// -- Set some other header information --
-
msg.setHeader("X-Mailer", "LOTONtechEmail");
-
msg.setSentDate(new Date());
-
// -- Send the message --
-
Transport.send(msg);
-
System.out.println("Message sent OK.");
-
}
-
catch (Exception ex)
-
{
-
System.out.println("Exception in send: " + ex.getMessage());
-
}
-
}
-
}
-
but when i run the program then i get an error ...... Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Message
plz help...
it's urgent
kind regards,
dmjpro.
6 1361
That package is supposed to be an extension so you should put that .jar in
the 'ext' directory under the lib directory of your JRE.
kind regards,
Jos
That package is supposed to be an extension so you should put that .jar in
the 'ext' directory under the lib directory of your JRE.
kind regards,
Jos
then why didn't i get the compiling error?
plz explain.
kind regards,
dmjpro.
then why didn't i get the compiling error?
plz explain.
kind regards,
dmjpro.
Ok i solved it.
but i have a new problem .. how can i get host name for a mail server... sayGMAIL server?
plz help.
kind regards,
Dmjpro.
Ok i solved it.
but i have a new problem .. how can i get host name for a mail server... sayGMAIL server?
plz help.
kind regards,
Dmjpro.
You can't; your program has to "know" it in advance. There is no service that
gives you a list of smtp servers anywhere in the world.
kind regards,
Jos
You can't; your program has to "know" it in advance. There is no service that
gives you a list of smtp servers anywhere in the world.
kind regards,
Jos
so do u know those server names for common use mail serveres????
plzzz say...
kind regards,
dmjpro.
so do u know those server names for common use mail serveres????
plzzz say...
kind regards,
dmjpro.
I only know the name of the smtp server supplied by my ISP.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: tyler_durden |
last post by:
thanks a lot for all your help..I'm really appreciated...
with all the help I've been getting in forums I've been able to continue
my program and it's almost done, but I'm having a big problem that...
|
by: jam |
last post by:
Dear All,
I am writing a console and it send a email out when it hits error
it calls this
static void SendErrorEmail(string error)
{
System.Web.Mail.MailMessage mail = new...
|
by: Erwan |
last post by:
I have a strange (but very blocking) result when using the smtpmail
class from an ASPX page :
here is the (very simple !) code...
'--------------------------------------------------
mail.To =...
|
by: B-Dog |
last post by:
I've built a small app that sends mail through our ISP's SMTP server but
when I try to send through my local exchange server I get CDO error. Does
webmail use SMTP or does it strictly rely on...
|
by: Nathan Sokalski |
last post by:
I am attempting to send an email using ASP.NET 1.1's Mail.SmtpMail.Send()
method. My code contains all of the following:
Dim mailmsg As New Mail.MailMessage
Mail.SmtpMail.SmtpServer =...
|
by: =?Utf-8?B?QWRl?= |
last post by:
HI All,
I am encountering the following error when I try to send an email through a
SMTP server. I believe the problem lies with the authentication part when the
network crednetials are used,...
|
by: satnamsarai |
last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail.
Unable to write data to the transport connection: An existing
connection was forcibly closed by the remote host.' Not sure how...
|
by: Dave Kelly |
last post by:
Sorry for the long post, it is easier to discard information than
to have to wait for it to arrive.
So here goes:
This code worked perfectly when I was an Earthlink customer. Sprint
decided...
|
by: happyse27 |
last post by:
Hi All,
I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |