Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Send Email with Form information

Reply
Thread Tools

Send Email with Form information

 
 
teser3@hotmail.com
Guest
Posts: n/a
 
      10-24-2007
--------------------------------------------------------------------------------
I have a Form with 10 fields on it and I need to send an email with
all 10 field values.

The form will pass the values to a Servlet which will call a JavaBean
class that will get the values and the email (JavaMail located in an
email helper class) part will be called in the Servelt to send the
JavaBean values. I assume I will also have to use the getMetaData
method to get the field names?

I dont have Struts or Sprint on my Tomcat 4.1.27 container.

Is this the right direction where the Email output will be similiar to
this:
First Name: Joe
Last Name: Smith
City: Dallas
State: Texas
.....

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      10-24-2007
On Tue, 23 Oct 2007 19:38:03 -0700, "(E-Mail Removed)"
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
said :

>I have a Form with 10 fields on it and I need to send an email with
>all 10 field values.


I think you will have better luck putting the URL of a form in your
email. That way you don't need to depend on the email program to
render it and send the data, something I suspect most email programs
would be reluctant to do.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      10-24-2007
Roedy Green wrote:
> On Tue, 23 Oct 2007 19:38:03 -0700, "(E-Mail Removed)"
> <(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
> said :
>
>> I have a Form with 10 fields on it and I need to send an email with
>> all 10 field values.

>
> I think you will have better luck putting the URL of a form in your
> email. That way you don't need to depend on the email program to
> render it and send the data, something I suspect most email programs
> would be reluctant to do.

Either you or I misinterpreted what the OP wanted. I understood him
wanting to have a web page with a form, that when he submitted it, an
e-mail was generated from the values in the form.

I didn't reply earlier, because I didn't feel like explaining the
processes of form submission, and how to retrieve the query args from
the request object, and then also connect to the JavaMail API to send
e-mail.

Hopefully, they can look into the JavaMail API themselves, and figure
out what they want to do.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
 
Reply With Quote
 
Manish Pandit
Guest
Posts: n/a
 
      10-24-2007
On Oct 23, 7:38 pm, "(E-Mail Removed)" <(E-Mail Removed)> wrote:
> --------------------------------------------------------------------------------
> I have a Form with 10 fields on it and I need to send an email with
> all 10 field values.
>
> The form will pass the values to a Servlet which will call a JavaBean
> class that will get the values and the email (JavaMail located in an
> email helper class) part will be called in the Servelt to send the
> JavaBean values. I assume I will also have to use the getMetaData
> method to get the field names?
>
> I dont have Struts or Sprint on my Tomcat 4.1.27 container.
>
> Is this the right direction where the Email output will be similiar to
> this:
> First Name: Joe
> Last Name: Smith
> City: Dallas
> State: Texas
> ....


You would not need to use reflection to get the field names (not sure
where the getMetaData API is coming from). In the servlet, you can
parse the request parameters by calling getParameterMap() on the
request. This will give you a map with key as the parameter name (the
name that you give in the form as <input type="text"
name="somename">), and the value is a String[]. Unless you have
checkboxes in the form, you should only worry about [0]. You can then
construct the email text by using parameter name and the value(s).

-cheers,
Manish

 
Reply With Quote
 
teser3@hotmail.com
Guest
Posts: n/a
 
      10-25-2007
Thanks, I am sending form info to people using JavaMail API.

I wanted to use getParameterMap() and Enumeration but it seems to
randomly
place the values in micleaneous order:

First Name: Joe
Last Name: Smith
City: Dallas
State: Texas

ends up looking like this sometimes:
City: Dallas
First Name: Joe
State: Texas
Last Name: Smith

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-25-2007
On Wed, 24 Oct 2007 09:22:46 -0700, Daniel Pitts
<(E-Mail Removed)> wrote, quoted or indirectly
quoted someone who said :

>Either you or I misinterpreted what the OP wanted. I understood him
>wanting to have a web page with a form, that when he submitted it, an
>e-mail was generated from the values in the form.


I thought he wanted to send somebody an email with an embedded form.
The user would enter data and it would be sent to a server.

For email generated from values in a form, see
http://mindprod.com/jgloss/javamail.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      10-25-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Thanks, I am sending form info to people using JavaMail API.
>
> I wanted to use getParameterMap() and Enumeration but it seems to
> randomly
> place the values in micleaneous order:
>
> First Name: Joe
> Last Name: Smith
> City: Dallas
> State: Texas
>
> ends up looking like this sometimes:
> City: Dallas
> First Name: Joe
> State: Texas
> Last Name: Smith
>

Form submission doesn't guaranty order of form elements. Neither does
the Map interface. If you know before hand what the value are, then you
can do something like this:

private static final List<String> keys = Arrays.asList("First Name",
"Last Name", "City", "State");

public void printValues(Map<String, String> map) {
for (String key: keys) {
System.out.println(key + ": " + map.get(key));
}
}

HTH.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      10-25-2007
(E-Mail Removed) wrote:
>> Thanks, I am sending form info to people using JavaMail API.
>>
>> I wanted to use getParameterMap() and Enumeration but it seems to
>> randomly
>> place the values in micleaneous order:


How are you getting an Enumeration? There is no method in java.util.Map to
return an Enumeration.

--
Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET send email -> Autheticate User information via LOTUS NOTES Eric Layman ASP .Net 3 05-10-2007 12:16 PM
How to have email form send email and start file download bmurphy@xlrotor.com Javascript 13 05-14-2006 06:27 PM
submit form, validate form, set cookie, send email, download file mhawkins19@adelphia.net Javascript 1 03-17-2005 08:19 AM
form - select option - send more information Jochen Fuhrmann HTML 1 01-12-2004 02:24 PM
HowTo:? open email client to send email Peter ASP .Net 0 07-01-2003 04:58 PM



Advertisments