v> Hi,
v> i am developing a system that will run on the company intranet. as a feature
v> of my software i want ppl to be able to send a mail. the company has a mail
v> server.
v> mailto is not a good option because it opens up a new message window. i
v> tried using the java mail class and included the mail.jar in jdk1.3.1/lib
v> and also included it in the class path. the servlet i wrote compiled but did
v> not run (as in it showed the page not found error).
v> please guide me asto how to go about implementing it.
v> please send me some code if somebody has worked on it.
v> i am a litle new to this servlet bussiness so kindly explain in simple
v> terms.
v> expecting good n swift help.
v> Vikas
try
this example:
MailSend.java
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class MailSend {
public static void main (String args[])
throws Exception {
String smtpHost = "your smtp server ip";
String from = "[EMAIL PROTECTED]";
String to = "[EMAIL PROTECTED]";
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", smtpHost);
// Get session
Session session = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Hello, Friend");
message.setText("Test mail");
// Send message
Transport.send(message);
}
}
Best regards,
Yuriy
___________________________________________________________________________
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