--- Nic Ferrier <[EMAIL PROTECTED]> wrote:
> >>> 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
Many thanks nic. I will put try block in the object
creation. I hope it will work. I was thining that
having a static boalean method that sends the mail in
that outside class. So the method returns true if the
email was sent or false if email was not sent. what do
you think of that approach?
sorry for this being off-topic.
thanks
roy
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/?.refer=text
___________________________________________________________________________
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