As I remember Javamail comes with examples on how to use it.
Here is the class and interface I wrote to mail text message, hope it can be
helpful:
import javax.mail.*;
import javax.mail.internet.*;
import java.util.Properties;
import java.util.Date;
// generic interface for sending mail,
// hiding concrete details which can be SMTP, POP#, MAPI, etc.
interface MailClient {
public void SendMail ( String smtpHost, String sender, String []
recipients, String subject, String text ) throws Exception;
}
class SMTPClient implements MailClient { // concrete implementaion for SMTP
protocol
public void SendMail ( String smtpHost, String sender, String []
recipients, String subject, String text ) throws Exception {
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpHost );
// Get a Session object
Session session = Session.getDefaultInstance(props, null);
// construct the message
Message msg = new MimeMessage(session);
if (sender != null)
msg.setFrom(new InternetAddress(sender));
else
msg.setFrom();
for (int i=0; i<recipients.length; i++ ) {
msg.addRecipients(Message.RecipientType.TO,
InternetAddress.parse(recipients[i]));
}
msg.setSubject(subject);
msg.setText(text);
msg.setHeader("X-Mailer", "Notify"); // ??? do we need to change the
default here???
msg.setSentDate(new Date());
// send the thing off
Transport.send(msg);
}
}
Vadim Shun
NEW Corp
Dulles, VA
-----Original Message-----
From: Xunming Liu [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 26, 2000 4:46 PM
Subject: How to forward the form data to another jsp file and email the
html form in the same time?
How to forward the form data to another jsp file and email the dynamic html
form
to specific email address in the same time?
I have installed the Javamail and JAF, But I don't know how to write the
code
although i've read so much useful information.
For a beginner the best way is just learn the example and follow it.
It will be greatly appreciated if any one email me detailed sample java
codes ,
JSP , HTML to email the dynamic HTML form.
Xunming
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets