aspose file tools*
The moose likes Servlets and the fly likes Exception in the mail servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Exception in the mail servlet" Watch "Exception in the mail servlet" New topic
Author

Exception in the mail servlet

Venkatachalapathi Madhes
Greenhorn

Joined: Aug 25, 2000
Posts: 2
I tried out the following mail servlet .
I got the exception NosuchProvider Exception
What I have to do?
I am using VisualAge.
How can solve this probelm
import javax.mail.internet.*;
import javax.mail.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class email extends HttpServlet
{

String smtphost;
public void doGet(javax.servlet.http.HttpServletRequest request,javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
{
mailsend();
}
public void mailsend()
{
try
{
java.util.Properties pro = System.getProperties();

pro.put("mail.smtp.host","matsystems");
pro.put("mail.transport.protocol","smtp");
//get the Session object to get control over service providers
Session ses = Session.getInstance(pro,null);
//create new message
Message mess = new MimeMessage(ses);


mess.setFrom(new InternetAddress("venhur@usa.net"));


mess.addRecipient(Message.RecipientType.TO, new InternetAddress("venhur100@yahoo.co.uk"));
System.out.println("to");

mess.setSubject("Hai");

mess.setText("pathi testing mail servlet");

System.out.println("Message over");

//Transport t = ses.getTransport("SMTP_MAIL");
//t.connect("matsystems","venhur@usa.net","ven100");
//t.send(mess);
//t.connect();
Transport.send(mess);

}
catch(AddressException ade)
{
System.out.println("Address exception");

}
catch(SendFailedException sfe)
{
System.out.println("send failed exception");

}
catch(NoSuchProviderException nop)
{
System.out.println("No such provider");
}
catch(MessagingException me)
{
System.out.println("messaging exception");

}


}
public void init(ServletConfig conf) throws javax.servlet.ServletException
{

super.init(conf);
smtphost=conf.getInitParameter("matsystems");

}

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in the mail servlet