• Post Reply Bookmark Topic Watch Topic
  • New Topic

Emailing form data in a portlet

 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I just started to work with porlets at my new project and need some help. I need to email some form data to an admin that the user enters. I have the form ok. I am assuming that when the user hits the send button on the form it will go to the processAction() method of the portlet. How do I send the form data to the admin from there?

Thanks,

AMD
 
Kawika King
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your processAction(ActionRequest ...), using apache commons e-mail...

// Get my form information (for each of your items)
String firstName = request.getParameter("firstn");

if (null != firstName) firstName = request.getParameter("firstn");

StringBuilder info = new StringBuilder(1);
info.append("FIRST NAME: ").append(firstName); //etc...

SimpleEmail email = new SimpleEmail();
email.setHostName("mail.myserver.com");
email.addTo("jdoe@somewhere.org", "John Doe");
email.setFrom("me@apache.org", "Me");
email.setSubject("Test message");
email.setMsg(info.toString());
email.send();

hth
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!