Posted By:
dB_Masters
Posted On:
Wednesday, March 21, 2001 05:07 AM
I have successfully emailed a small message using the following script: <%@ page import=" javax.mail.*, javax.mail.internet.*, javax.activation.*,java.util.*" %> <% try{ Properties props = new Properties(); Session sendMailSession; Store store; Transport transport; sendMailSession = Session.getInstance(props, null); props.put("mail.******.com"); Message newMessage = new MimeMessage(sendMailSession); newMessage.setFrom(new InternetAddress(request.getParameter("from"))); newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(request
More>>
I have successfully emailed a small message using the following script:
<%@ page
import=" javax.mail.*, javax.mail.internet.*, javax.activation.*,java.util.*"
%>
<%
try{
Properties props = new Properties();
Session sendMailSession;
Store store;
Transport transport;
sendMailSession = Session.getInstance(props, null);
props.put("mail.******.com");
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("text"));
transport = sendMailSession.getTransport("smtp");
transport.send(newMessage);
%>
Your mail has been sent.
<%
}
catch(MessagingException m)
{
out.println(m.toString());
}
%>
But as soon as I add more fields to go in the body of the message I get compilation errors. Logically, I have tried to add them by copying the setText line from above and just inserting the new field name like so:
newMessage.setText(request.getParameter("newfield"));
and
newMessage.setNewField(request.getParameter("newfield"));
what am I doing wrong? Thanks for any help...
<<Less