Forums

This topic is locked

JMail help?

Posted 19 Mar 2001 23:16:41
1
has voted
19 Mar 2001 23:16:41 Cain Ullah posted:
I am trying to send values in form objects to an e-mail address. I have
passed the 'from', 'to' and 'subject' parameters from my orders page to my
confirmation page. It sends the value from the drop down box 'MenDate'
correctly. However I also want to send the contents of the other form
objects. Being drop downs and text fields. I have used the code below with
JMail on a JSP page. Can anyone help me? I tried copying and pasting the
newMessage.setText line with a different parameter but it didn't work. I
also want to display all the information on the confirmation page instead of
the line Your Message was sent. Any ideas?

I only downloaded JMail a few days ago and have two weeks to hand in my
webpage for my degree.
Most Grateful
Cain


<form name="Confirmation" method="get" action="">
<%

try{
Properties props = new Properties();
Session sendMailSession;
Store store;
Transport transport;


sendMailSession = Session.getInstance(props, null);

props.put("mail.smtp.host", "smtp.freeserve.net";

Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress(request.getParameter("from"));
newMessage.setRecipient(Message.RecipientType.TO, new
InternetAddress(request.getParameter("to"));
newMessage.setSubject(request.getParameter("subject");
newMessage.setSentDate(new Date());
newMessage.setText(request.getParameter("MenDate");

transport = sendMailSession.getTransport("smtp";
transport.send(newMessage);
%>
<P> Your Message Was Sent</P>
<%
}
catch(MessagingException m)
{
out.println(m.toString());
}
%>

</form>



Reply to this topic