>>> roy woods <[EMAIL PROTECTED]> 01-Apr-01 8:42:54 PM >>>

>I have a class that sends email from servlet and it
>working fine when I use it as a single class it works
>and the mail is sent successfully but when I try to
>create an object of this class to send the message I
>get this: Exception javax.mail.MessagingException must
>be caught or it must be declared in throws clause of
>this method
>
>jm = new JavaMailer(note, sender);
>

But you have to catch the exception where you create the instance
(since the cons throws the exception).

So it's the code where you create the instance that is the problem,
not your cons, eg:

 try
 {
    jim=new JavaMailer(note,sender);
 }
 catch(MessagingException e)
 {
     //whoops!
  }


Writing a class like this is generally a bad idea... if you need to
do this write a static method in a class. Have it return a small class
that contains the information you want if you need contained return
values, alternately just return the Message you sent.

BTW you're problem is not related to servlets and is in fact a
general java question. You shouldn't really ask it here.


Nic Ferrier

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to