Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Mail

Status
Not open for further replies.

sensory21

Programmer
Jan 27, 2004
79
GB
Hi all,

has anyone installed JFormMail written in Java as I have problems installing it?
Or maybe have you got any suggestions about having a mail form on a jsp page?

Cheers
Vero
 
Hi,

What exactly are you looking for ? You want to have a facility to send an E-Mail from JSP ?

Cheers,
Venu
 
Are you sure you went through the JavaMail tutorial correctly ? I cannot see that this example is too tricky - try it !
(from )
Code:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;

public class MailExample {
  public static void main (String args[]) throws Exception {
    String host = args[0];
    String from = args[1];
    String to = args[2];

    // Get system properties
    Properties props = System.getProperties();

    // Setup mail server
    props.put("mail.smtp.host", host);

    // Get session
    Session session = Session.getDefaultInstance(props, null);

    // Define message
    MimeMessage message = new MimeMessage(session);

    // Set the from address
    message.setFrom(new InternetAddress(from));

    // Set the to address
    message.addRecipient(Message.RecipientType.TO, 
      new InternetAddress(to));

    // Set the subject
    message.setSubject("Hello JavaMail");

    // Set the content
    message.setText("Welcome to JavaMail");

    // Send message
    Transport.send(message);
  }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top