• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending a receipt after filling out the form.

 
Kirk Martin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form and I�m trying to figure out how to send the customer an email after they fill out the form. I want to add on the email the time and date they signed up so i'm assuming use <%=request.getParameter("")%>.

I also want to add a link that will delete the appointment from the database if they decide to cancel the appointment. So if they click on the link it will delete their appointment. Any help will be appreciated. Any tutorials online would be great also can't find any myself.
[ December 13, 2004: Message edited by: Kirk Martin ]
 
sureshbabu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,


1) Download the activation.jar and mail.jar and set the classpath
2) Write a servlet or JSP which accepts the input parameters
3) Look into this API http://java.sun.com/j2ee/sdk_1.3/techdocs/api/ to use the corresponding classes

Here is the sample code :
private static void sendMail(String toAddress,String message,String mailHost,String fromAddress,String mailSubject,String contentType) throws javax.mail.MessagingException
{
Properties sysProps = System.getProperties();

// Setup mail server
sysProps.put("mail.smtp.host", mailHost);
// Get Mailing Session
Session mailSession = Session.getInstance(sysProps, null);

// Define message
Message mimeMessage = new MimeMessage(mailSession);

mimeMessage.setFrom(new InternetAddress(fromAddress));
StringTokenizer addresses = new StringTokenizer(toAddress, ",");
while (addresses.hasMoreTokens())
{
mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(addresses.nextToken()));
}

try
{
mailSubject = MakeRFC2047.encode(mailSubject ,"UTF8");
mimeMessage.setSubject(mailSubject);
}
catch(java.io.UnsupportedEncodingException e)
{
System.out.println("UnsupportedEncodingException"+e.getMessage());// This is know to be a supported encoding and anyway there's nothing to be done if we can't convert
}

mimeMessage.setContent(message, contentType);
// Send message
Transport.send(mimeMessage);
}

4) You can also add the link as part of the message body and call a JSP(or servlet) to recieve the parameters based on which you can delete the values in the database


Suresh
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"salomiya",

We're pleased to have you here with us here on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!